[Wheat-cvs] r1/root/library compiler.ws,NONE,1.1 base.ws,1.59,1.60
Status: Pre-Alpha
Brought to you by:
mark_lentczner
From: Jim K. <ki...@us...> - 2005-05-05 17:42:49
|
Update of /cvsroot/wheat/r1/root/library In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26076/root/library Modified Files: base.ws Added Files: compiler.ws Log Message: Split compiler tests out of base.ws and put them in compiler.ws. --- NEW FILE: compiler.ws --- wheat(version: 1) ``( Tests that go with compiler-test.cpp, but which I'd rather write in wheat (most tests in compiler-test are perhaps candidates). ``) tests: {:'/library/wheatunit/test-case': -- public -- test-unknown-global(): { unknown := $no-such-member; known := $sample-member; `` Why ??? and not error? #assert-equals(???, unknown); if (unknown?) { #fail(); } else { #pass(); } #assert-equals(false, unknown?); if (known?) { #pass(); } else { #fail(); } #assert-equals(true, known?); } -- private -- sample-member: 5; -- public -- test-test-for-unknown(): { unknown-value := ???; known-value := 5; #assert-equals(true, 5?); #assert-equals(true, known-value?); #assert-equals(false, ??? ?); #assert-equals(false, unknown-value?); `` Probably want the error to propagate, so error-value? is `` the error itself. Currently, error is considered known (yuck). (error-value := !!!("bad"))!; #assert-equals(true, error-value?); #assert-equals(true, !!!("also bad") ?); } `` Only problem is, THERE IS NO BREAK STATEMENT! `` (Looking at ScriptCompiler, it would appear that break `` is currently implemented as a noop). test-break(): { i := 0; while (i < 5) { if (i == 1) { break; } i += 1; } #assert-equals(5, i); `` #assert-equals(1, i); } `` The real problem that motivated this test was trying to `` erroneously advance the control variable of a loop with ++i. `` The error check doesn't help, because we never get out of the loop. test-plusplus(): { i := 0; (error := ++i)!; #assert-error("system/vm/exception/not-found(++)", error); } } Index: base.ws =================================================================== RCS file: /cvsroot/wheat/r1/root/library/base.ws,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- base.ws 30 Apr 2005 04:42:34 -0000 1.59 +++ base.ws 5 May 2005 17:42:25 -0000 1.60 @@ -989,75 +989,6 @@ model: { :'/library/base/enum': values: ["corolla", "prius", "civic"] } - `` Tests that go with compiler-test.cpp, but which I'd rather write in - `` wheat (most tests in compiler-test are perhaps candidates). - `` Probably we should have a compiler.ws or some such for these to live in. - -- public -- - test-unknown-global(): { - unknown := $/library/base/tests/no-such-member; - known := $/library/base/tests/sample-member; - - `` Why ??? and not error? - #assert-equals(???, unknown); - if (unknown?) { - #fail(); - } else { - #pass(); - } - #assert-equals(false, unknown?); - if (known?) { - #pass(); - } else { - #fail(); - } - #assert-equals(true, known?); - } - -- private -- - sample-member: 5; - - -- public -- - - test-test-for-unknown(): { - unknown-value := ???; - known-value := 5; - #assert-equals(true, 5?); - #assert-equals(true, known-value?); - #assert-equals(false, ??? ?); - #assert-equals(false, unknown-value?); - - `` Probably want the error to propagate, so error-value? is - `` the error itself. Currently, error is considered known (yuck). - (error-value := !!!("bad"))!; - #assert-equals(true, error-value?); - #assert-equals(true, !!!("also bad") ?); - } - - `` Only problem is, THERE IS NO BREAK STATEMENT! - `` (Looking at ScriptCompiler, it would appear that break - `` is currently implemented as a noop). - test-break(): { - i := 0; - while (i < 5) { - if (i == 1) { - break; - } - i += 1; - } - #assert-equals(5, i); -`` #assert-equals(1, i); - } - - `` The real problem that motivated this test was trying to - `` erroneously advance the control variable of a loop with ++i. - `` The error check doesn't help, because we never get out of the loop. - test-plusplus(): { - i := 0; - (error := ++i)!; - #assert-error("system/vm/exception/not-found(++)", error); - } - - `` end compiler-test.cpp-like tests - -- public -- test-path-trail-expander(): { html := $/library/render.expand( |