-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test104.ts
50 lines (31 loc) 路 757 Bytes
/
test104.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Evt } from "../lib/index.ts";
import { assert } from "https://deno.land/x/tsafe@v1.1.1/assert.ts";
const log = console.log;
(async () => {
const timer = setTimeout(
()=> {
assert(false);
},
3000
);
const console = { "log": (str: string | number) => console.stdOut += `${str}`, "stdOut": "" };
const evtCounter = Evt.create<number>(0);
const intervalTimer = setInterval(
()=> {
evtCounter.state++;
},
100
);
for await (const counter of evtCounter) {
console.log(counter);
if( counter === 3 ){
break;
}
}
console.log("loop_end");
assert(console.stdOut === "0123loop_end");
clearTimeout(timer);
clearInterval(intervalTimer);
assert(evtCounter.getHandlers().length === 0);
log("PASS");
})();