refactor basic tests for cond

This commit is contained in:
2021-11-14 22:50:25 -07:00
parent e884b2636e
commit 50cb51548e
2 changed files with 21 additions and 22 deletions

View File

@@ -156,10 +156,7 @@ class BasicTestCase extends Test {
} }
function testCond() { function testCond() {
Assert.equals("this one", BasicTestCase.myCond1); _testCond();
Assert.equals("the default", BasicTestCase.myCond2);
Assert.equals("this", BasicTestCase.myCond3);
Assert.equals(null, BasicTestCase.myCondFallthrough);
} }
function testSetAndDeflocal() { function testSetAndDeflocal() {

View File

@@ -153,24 +153,26 @@
(var myConstructedString (new String "sup")) (var myConstructedString (new String "sup"))
(var myCond1 (cond (function _testCond []
((= 5 6) "not this") (Assert.equals "this one"
((= 8 9) "not this either") (cond
((= 1 1) "this one") ((= 5 6) "not this")
(true "not the default"))) ((= 8 9) "not this either")
((= 1 1) "this one")
(var myCond2 (cond (true "not the default")))
((= 5 6) "not this") (Assert.equals "the default"
((= 8 9) "not this either") (cond
((= 2 1) "not the third one") ((= 5 6) "not this")
(true "the default"))) ((= 8 9) "not this either")
((= 2 1) "not the third one")
(var myCond3 (cond (true "the default")))
((= 5 5) "this") (Assert.equals "this"
(true "default"))) (cond
((= 5 5) "this")
(var myCondFallthrough (cond (true "default")))
(false "not this"))) (Assert.equals null
(cond
(false "not this"))))
(function _testOr [] (function _testOr []
(Assert.equals 5 (or null 5)) (Assert.equals 5 (or null 5))