basic (case...)

This commit is contained in:
2020-12-07 07:37:57 -07:00
parent 3965e35d6d
commit 40b91ec6be
3 changed files with 53 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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))))