forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.ts
More file actions
56 lines (43 loc) · 1.29 KB
/
tests.ts
File metadata and controls
56 lines (43 loc) · 1.29 KB
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
51
52
53
54
55
56
import {
setTimeout, setImmediate, setInterval,
clearImmediate, clearInterval, clearTimeout
} from "./index.js";
import { world } from "@minecraft/server";
function stdout (...data: any[]): any {
return world.getDimension("overworld").runCommandAsync(`say §r` + data.join(" "));
};
function stderr (...data: any[]): any {
return world.getDimension("overworld").runCommandAsync(`say §c` + data.join(" "));
};
// timeout test
setTimeout(function (arg, arg1) {
stdout("arg", arg, "arg1", arg1);
}, 1000, "hello", "world", 1);
stdout("setTimeout passed");
// cleartimeout test
let timeout2 = setTimeout(function () {
stderr("clearTimeout failed");
}, 1000);
clearTimeout(timeout2);
stdout("clearTimeout passed");
// setinterval test
let interval = setInterval(function (arg, arg1) {
stdout("arg", arg, "arg1", arg1);
}, 1000, "set", "interval", 1);
stdout("setTimeout passed");
// clearinterval test
interval._onTimeout = () => {
stderr("clearInterval failed");
};
clearInterval(interval);
stdout("clearInterval passed");
// setimmediate test
setImmediate(function () {
stdout("setImmediate passed");
});
// clearimmediate test
let immediate = setImmediate(function () {
stderr("setImmediate failed");
});
clearImmediate(immediate);
stdout("clearImmediate passed");