awaitLet test case. Close #71
This commit is contained in:
@@ -7,6 +7,9 @@ import kiss.List;
|
|||||||
import kiss.Stream;
|
import kiss.Stream;
|
||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
import kiss.Kiss;
|
import kiss.Kiss;
|
||||||
|
#if js
|
||||||
|
import js.lib.Promise;
|
||||||
|
#end
|
||||||
|
|
||||||
using StringTools;
|
using StringTools;
|
||||||
|
|
||||||
@@ -413,6 +416,12 @@ class BasicTestCase extends Test {
|
|||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#if js
|
||||||
|
function testAwaitLet(async:utest.Async) {
|
||||||
|
_testAwaitLet(async);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
var aNullToPrint = null;
|
var aNullToPrint = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -771,3 +771,41 @@ From:[(assert false (+ \"false \" \"should \" \"have \" \"been \" \"true\"))]" m
|
|||||||
([:String a :Int five :Float fivePointFive :Bool tt]
|
([:String a :Int five :Float fivePointFive :Bool tt]
|
||||||
(Assert.equals "a55.5true" "${a}${five}${fivePointFive}${tt}"))
|
(Assert.equals "a55.5true" "${a}${five}${fivePointFive}${tt}"))
|
||||||
(never otherwise)))
|
(never otherwise)))
|
||||||
|
|
||||||
|
(function _testAwaitLet [:utest.Async async]
|
||||||
|
(localFunction :Promise<Bool> newPromise [:Bool succeed]
|
||||||
|
(new Promise
|
||||||
|
->:Void [
|
||||||
|
:Bool->Void resolve
|
||||||
|
:Dynamic->Void reject
|
||||||
|
] (if succeed (resolve true) (reject false))))
|
||||||
|
|
||||||
|
(awaitLet [result (newPromise true)]
|
||||||
|
(catch [:Dynamic e] (Assert.fail))
|
||||||
|
(Assert.isTrue result)
|
||||||
|
(awaitLet [res1 (newPromise false)
|
||||||
|
res2 (newPromise true)
|
||||||
|
res3 (newPromise true)]
|
||||||
|
(catch [:Dynamic e]
|
||||||
|
(Assert.isFalse e)
|
||||||
|
(awaitLet [res1 (newPromise true)
|
||||||
|
res2 (newPromise false)
|
||||||
|
res3 (newPromise true)]
|
||||||
|
(catch [:Dynamic e]
|
||||||
|
(Assert.isFalse e)
|
||||||
|
(awaitLet [res1 (newPromise true)
|
||||||
|
res2 (newPromise true)
|
||||||
|
res3 (newPromise false)]
|
||||||
|
(catch [:Dynamic e]
|
||||||
|
(Assert.isFalse e)
|
||||||
|
(awaitLet [res1 (newPromise true)
|
||||||
|
res2 (newPromise res1)
|
||||||
|
res3 (newPromise res2)]
|
||||||
|
(Assert.isTrue ?(and res1 res2 res3))
|
||||||
|
(async.done))
|
||||||
|
e)
|
||||||
|
(Assert.fail))
|
||||||
|
e)
|
||||||
|
(Assert.fail))
|
||||||
|
e)
|
||||||
|
(Assert.fail))))
|
Reference in New Issue
Block a user