-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimerTests.hx
More file actions
56 lines (48 loc) · 1.14 KB
/
TimerTests.hx
File metadata and controls
56 lines (48 loc) · 1.14 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
package;
class TimerTests {
var t:Main;
public function new(main:Main) {
t = main;
}
public function run() {
t.section("TimerStamp");
checkStamp();
t.section("TimerStampIncreasing");
checkStampIncreasing();
t.section("TimerDelay");
checkDelay();
t.section("TimerMeasure");
checkMeasure();
t.section("TimerNewStop");
checkNewStop();
}
function checkStamp() {
var s = haxe.Timer.stamp();
var isNonNeg = s >= 0;
t.isTrue(isNonNeg, "stamp returns non-negative");
}
function checkStampIncreasing() {
var s1 = haxe.Timer.stamp();
var s2 = haxe.Timer.stamp();
var ok = s2 >= s1;
t.isTrue(ok, "second stamp >= first stamp");
}
function checkDelay() {
// Blocking delay in BRS — just verify it completes
haxe.Timer.delay(function() {
trace("delay fired");
}, 1);
t.isTrue(true, "delay completes without error");
}
function checkMeasure() {
var result = haxe.Timer.measure(function() {
return 42;
});
t.intEquals(42, result, "measure returns function result");
}
function checkNewStop() {
var timer = new haxe.Timer(100);
timer.stop();
t.isTrue(true, "new/stop completes without error");
}
}