Differential D2666 Diff 11926 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]); | TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]); | ||||
fired = []; | fired = []; | ||||
cancelId = cmpTimer.SetInterval(20, IID_Test, "Callback", 500, 1000, "s"); | cancelId = cmpTimer.SetInterval(20, IID_Test, "Callback", 500, 1000, "s"); | ||||
cmpTimer.OnUpdate({ "turnLength": 3.0 }); | cmpTimer.OnUpdate({ "turnLength": 3.0 }); | ||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["s",2500]]); | TS_ASSERT_UNEVAL_EQUALS(fired, [["s",2500]]); | ||||
fired = []; | |||||
let f = cmpTimer.SetInterval(10, IID_Test, "Callback", 1000, 1000, "f"); | |||||
cmpTimer.OnUpdate({ "turnLength": 1 }); | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0]]); | |||||
cmpTimer.OnUpdate({ "turnLength": 1 }); | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0]]); | |||||
cmpTimer.UpdateRepeatTime(f, 500); | |||||
cmpTimer.OnUpdate({ "turnLength": 1.5 }); | |||||
// Interval updated at next updated, so expecting latency here. | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0], ["f", 500], ["f", 0]]); | |||||
cmpTimer.OnUpdate({ "turnLength": 0.5 }); | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0], ["f", 500], ["f", 0], ["f", 0]]); |
Wildfire Games · Phabricator