Hi Erich, Erich Waelde <ew.fo...@nassur.net> writes:
> Hello, > > since I just found out, how easy it is, to write test cases > and run them, I thought I'd share a few lines on this. > Matthias: feel free to add this to the cookbook. > > > So you want to write test cases for you new function? Load > lib/ans94/core/postpone.frt > lib/ans94/core-ext/marker.frt > they will be needed. > > The tester uses 4 words: > TESTING add your comment here > is a "talking comment" to make the output somehow look nice. > { > starts a new test. Prepare the stack and call your function, then > -> > indicates that the test code is complete. Add the remaining stack after > this word. > } > completes the test by comparing the stack with the expected stack. If > everything is well, the ok prompt will appear. > > A test summary is not printed, but that could > > > Write a file with your new library function, e.g. > \ function.frt > \ define some new function > : plus + ; > > Then write the test cases, e.g. > \ function-test.frt > > \ load the tester > include lib/ans94/tester/tester-amforth.frt > > \ load the code under test > include function.frt > > \ run the tests > TESTING the tester ----------------------------------------- > > { 1 1 + -> 2 } > { 1 1 plus -> 2 } > { 1 1 plus -> 3 } \ incorrect > { 1 2 plus -> 3 } \ tester contiues > { $FFFF 1 plus -> 0 } > { 1 2 3 4 plus -> 1 2 7 } > > Now load the file 'function-test.frt' to the controller and watch > the show. > TESTING the tester ----------------------------------------- > ok > > { 1 1 + -> 2 } > ok > > { 1 1 plus -> 2 } > ok > > { 1 1 plus -> 3 } > INCORRECT RESULT: { 1 1 plus -> 3 } > ok > > { 1 2 plus -> 3 } > ok > > { $FFFF 1 plus -> 0 } > ok May I draw attention to an alternative testing method through Keith's amforth-shell.py. Here's a test I put in lib/crc8.frt \ verify having 256 pad bytes to form the crc table \ #expect-output-next ^-1 0 $ s" /pad" environment? . 256 < . Regards, Enoch. ------------------------------------------------------------------------------ Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel