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() {
Assert.equals("this one", BasicTestCase.myCond1);
Assert.equals("the default", BasicTestCase.myCond2);
Assert.equals("this", BasicTestCase.myCond3);
Assert.equals(null, BasicTestCase.myCondFallthrough);
_testCond();
}
function testSetAndDeflocal() {

View File

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