basic (case...)
This commit is contained in:
@@ -4,6 +4,7 @@ import utest.Test;
|
||||
import utest.Assert;
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
import haxe.ds.Option;
|
||||
|
||||
using StringTools;
|
||||
|
||||
@@ -237,6 +238,10 @@ class BasicTestCase extends Test {
|
||||
function testAnonymousObject() {
|
||||
_testAnonymousObject();
|
||||
}
|
||||
|
||||
function testCase() {
|
||||
_testCase();
|
||||
}
|
||||
}
|
||||
|
||||
class BasicObject {
|
||||
|
@@ -325,4 +325,18 @@
|
||||
a "string A"
|
||||
b 5)]
|
||||
(Assert.equals "string A" obj.a)
|
||||
(Assert.equals 5 obj.b)))
|
||||
(Assert.equals 5 obj.b)))
|
||||
|
||||
(defun toOption [:Dynamic value]
|
||||
(if value (Some value) None))
|
||||
|
||||
(defun _testCase []
|
||||
(case (toOption [])
|
||||
(None (Assert.pass))
|
||||
((Some value) (Assert.fail)))
|
||||
(case (toOption "hey")
|
||||
(None (Assert.fail))
|
||||
((Some "hey") (Assert.pass))
|
||||
(otherwise (Assert.fail)))
|
||||
(Assert.equals 5 (case (toOption 0)
|
||||
(otherwise 5))))
|
Reference in New Issue
Block a user