ifLet
This commit is contained in:
@@ -269,6 +269,10 @@ class BasicTestCase extends Test {
|
||||
function testAssignArith() {
|
||||
_testAssignArith();
|
||||
}
|
||||
|
||||
function testPatternLets() {
|
||||
_testPatternLets();
|
||||
}
|
||||
}
|
||||
|
||||
class BasicObject {
|
||||
|
@@ -436,4 +436,20 @@
|
||||
(/= num 25 2)
|
||||
(Assert.equals 1 num)
|
||||
(-= num 5 6)
|
||||
(Assert.equals -10 num))
|
||||
(Assert.equals -10 num))
|
||||
|
||||
(defun _testPatternLets []
|
||||
(let [some5 (Some 5)
|
||||
some6 (Some 6)
|
||||
none None
|
||||
:Null<Option<Any>> oops null]
|
||||
(ifLet [(Some a) some5
|
||||
(Some b) some6]
|
||||
(Assert.equals 11 (+ a b))
|
||||
(Assert.fail))
|
||||
(ifLet [(Some a) oops]
|
||||
(Assert.fail))
|
||||
(ifLet [(Some (or 5 6)) some5]
|
||||
(Assert.pass))
|
||||
(ifLet [(Some a) none]
|
||||
(Assert.fail))))
|
Reference in New Issue
Block a user