repl very nice + question on test framework

11 views
Skip to first unread message

Jason E. Aten

unread,
Dec 20, 2012, 7:02:07 PM12/20/12
to crack-l...@googlegroups.com, Michael Muller, Shannon Weyrick
A quick question and a progress report.

Question: could someone explain how to add tests, perhaps give an overview
of how the test system works?

And now, the latest repl progress:

+ redefinitions are allowed. Classes, functions, variables can all be re-defined
  at the repl. If you make a mistake, no big deal. Just type it again.

+ syntax errors in classes don't trash the repl state by generating unfinished
  llvm code. (Actually they do, we just check for dangling half-finished llvm functions
  without terminators, and delete them, so as to recover cleanly.) Plus we
  log all namespace additions in a transaction so we can roll them back
  cleanly on syntax errors.

+ .dc sym  will list the llvm code for just sym, per Shannon's request.

+ code updated per Micheal's comments; a few things still on TODO list. See Construct.cc.


So give it a try, it's pretty awesome.


How to get the latest: it is on a branch called 'prepurgedanglers', so:

git clone https://github.com/glycerine/crack-language.git
git checkout prepurgedanglers
./bootstrap; ./configure; make

# to look at diffs vs trunk...
# git remote add shannon   https://github.com/weyrick/crack-language.git
# git fetch shannon
# git diff shannon/master > patches

Quick demo of class redefinition:

$ ./crack
wisecrack read-eval-print-loop [type .help for hints]
(1:crk) class A { if ;
ParseError: (1:crk):1:11: token if was not expected at this time, type identifier expected

(2:crk) .ls  #verify no remnants of A left in .repl namesapce
.repl (0x0x150d648) {
  .builtin.:ExStruct :exStruct
}
(3:crk) class A {}  # verify we can define class after an error
(4:crk) A a = A();
(5:crk) .
a = <Object>
(6:crk) class A { oper init() { cout `A::init() called!\n`; } }  # verify we can redefine classes
(7:crk) A a = A();
A::init() called!
(8:crk) class A { oper init() { cout `redefinition of A::init() called!\n`; } } # and again
(9:crk) A a = A();
redefinition of A::init() called!
(10:crk) a:=10;
(11:crk) .
a = 10
(12:crk)


Happy Holidays!

Jason

Michael Muller

unread,
Dec 21, 2012, 9:35:53 AM12/21/12
to Jason E. Aten, crack-l...@googlegroups.com, Shannon Weyrick

Jason E. Aten wrote:
> A quick question and a progress report.
>
> Question: could someone explain how to add tests, perhaps give an overview
> of how the test system works?

Add a .crkt file to screen/tests/1_post_bs. You can see the files there for
examples, it's basically comprised of several sections with a certain canned
set of substitutions. The 1_post_bs tests are the tests that depend on
bootstrapping (which is the process of importing the crack/lang.crk file,
where certain very basic elements of the language are defined). The 0_pre_bs
tests test language features that work before bootstrapping.

The test suite is run from the test/screen shell-script, which generally
attempts to build the "screen" test program. The test program runs through
the 0_pre_bs and 1_post_bs directories and processes any files that are in
there.

There's also a screen/tests/optional directory that contains test programs
that depend on external libraries that need not be installed (like ALSA and
SSL). We don't normally run this, so if you want to make sure that nobody
breaks your feature in the course of normal development, best to put in in the
"basic" tests.

>
> And now, the latest repl progress:
>
> + redefinitions are allowed. Classes, functions, variables can all be
> re-defined
> at the repl. If you make a mistake, no big deal. Just type it again.
>
> + syntax errors in classes don't trash the repl state by generating
> unfinished
> llvm code. (Actually they do, we just check for dangling half-finished
> llvm functions
> without terminators, and delete them, so as to recover cleanly.) Plus we
> log all namespace additions in a transaction so we can roll them back
> cleanly on syntax errors.
>
> + .dc sym will list the llvm code for just sym, per Shannon's request.
>
> + code updated per Micheal's comments; a few things still on TODO list. See
> Construct.cc.
>
>
> So give it a try, it's pretty awesome.

I'll definitely play with it over the holiday break!
=============================================================================
michaelMuller = mmu...@enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
If you are not willing to control your own mind, there are plenty of other
people who are willing to do it for you.
=============================================================================

Jason E. Aten

unread,
Dec 21, 2012, 2:47:28 PM12/21/12
to Michael Muller, Shannon Weyrick, crack-l...@googlegroups.com
On Fri, Dec 21, 2012 at 6:35 AM, Michael Muller <mmu...@enduden.com> wrote:

Jason E. Aten wrote:
> A quick question and a progress report.
>
> Question: could someone explain how to add tests, perhaps give an overview
> of how the test system works?

Add a .crkt file to screen/tests/1_post_bs.  You can see the files there for
examples, it's basically comprised of several sections with a certain canned
set of substitutions.  The 1_post_bs tests are the tests that depend on
bootstrapping (which is the process of importing the crack/lang.crk file,
where certain very basic elements of the language are defined).  The 0_pre_bs
tests test language features that work before bootstrapping.

The test suite is run from the test/screen shell-script, which generally
attempts to build the "screen" test program.  The test program runs through
the 0_pre_bs and 1_post_bs directories and processes any files that are in
there.

There's also a screen/tests/optional directory that contains test programs
that depend on external libraries that need not be installed (like ALSA and
SSL).  We don't normally run this, so if you want to make sure that nobody
breaks your feature in the course of normal development, best to put in in the
"basic" tests.

Thanks!  I've been wanting to add tests, but I didn't get the pre_bs vs post_bs and basic vs options. These make alot of sense. I'll give it a go.

Once I've added new test file, say it's called
screen/tests/basic/1_post_bs/200_repl_starts.crkt

How would I run just this new 200 test, so I can see that it's broken/working without waiting for all the other tests to run?

Thanks!

Best,
Jason

Michael Muller

unread,
Dec 21, 2012, 2:48:23 PM12/21/12
to Jason E. Aten, Shannon Weyrick, crack-l...@googlegroups.com
test/screen screen/tests/basic/1_post_bs/200_repl_starts.crkt

>
> Thanks!
>
> Best,
> Jason
>


=============================================================================
michaelMuller = mmu...@enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
The world is full of security systems. Hack one of them. - Bruce Schneier
=============================================================================

Jason E. Aten

unread,
Dec 21, 2012, 2:50:36 PM12/21/12
to Michael Muller, Shannon Weyrick, crack-l...@googlegroups.com
On Fri, Dec 21, 2012 at 11:48 AM, Michael Muller <mmu...@enduden.com> wrote:
test/screen screen/tests/basic/1_post_bs/200_repl_starts.crkt

Perfect. Thanks!

Shannon Weyrick

unread,
Dec 23, 2012, 4:13:51 PM12/23/12
to crack-l...@googlegroups.com, Michael Muller, Shannon Weyrick
Jason, finally got a chance to play with it and it's looking really good. Found a few small things though, here's a sample script:

weyrick@blesk:~/workspace/crack-repl/build$ ./crack
wisecrack read-eval-print-loop [type .help for hints]
(1:crk) a := 5;
(2:crk) . a
ParseError: (2:crk):1:1: Unknown identifier cout

(3:crk) .
a = 5
(4:crk) . a
a = 5
(5:crk) .dc a
.dc 'a' error: I don't know how to dump code for type 'int' yet.
(6:crk) 
(7:crk) ~Namespace dtor firing on 0x1372940
~Namespace dtor firing on 0xd74580

on line 6 I pressed Ctrl-D. Note this is before your editline patch which I haven't played with yet.

Did I misunderstand what ".dc a" should do, or is that not working?

Shannon

j.e....@gmail.com

unread,
Dec 23, 2012, 6:04:35 PM12/23/12
to Shannon Weyrick, crack-l...@googlegroups.com, Michael Muller, Shannon Weyrick
Hi Shannon,

I'm glad you are putting the repl through it paces.  I noticed those issues last night, and fixes are in the head of the prepurgedanglers branch.

The .dc sym (dump code for symbol)  is either a fire hose or a trickle of data at the moment. In trickle mode, with a symbol specified, it really only works for functions. In firehose mode it shows all the llvm code (type just .dc alone, no symbol specified), presently. The .ls will show the types of variables, and what is visible, so that is often quite helpful too, for seeing the type of variables.

Best,
Jason


Sent from my Verizon Wireless Phone
Reply all
Reply to author
Forward
0 new messages