Changeset View
Changeset View
Standalone View
Standalone View
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]]); | ||||
function testUpdateRepeatTime() | |||||
bb: No need for function | |||||
{ | |||||
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 }); | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0], ["f", 500], ["f", 0]]); | |||||
bbUnsubmitted Not Done Inline ActionsAdding a comment why this is actually correct. bb: Adding a comment why this is actually correct.
| |||||
cmpTimer.OnUpdate({ "turnLength": 0.5 }); | |||||
TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0], ["f", 500], ["f", 0], ["f", 0]]); | |||||
}; | |||||
testUpdateRepeatTime(); |
Wildfire Games · Phabricator
No need for function