Page MenuHomeWildfire Games

Allow to update repeat time of running timer.
ClosedPublic

Authored by Freagarach on Mar 24 2020, 8:24 PM.

Details

Summary

If some modification is applied to a repeat time of a timer, the timer is not updated so the only way of using the new value is by stopping the timer and starting it again (cf. D818).
This might have unintended side effects such as not being able to execute the timer at all.

This diff adds a function to cmpTimer.js to update the repeat time of a specific timer.
A use case could be D818.

Test Plan

Verify that the change is correct and think of possible ways to break this.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Freagarach created this revision.Mar 24 2020, 8:24 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...

binaries/data/mods/public/simulation/components/Timer.js
|  63| »   if·(typeof·repeattime·!=·"number"·||·!(repeattime·>·0))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'Callback' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|   8|   8| var fired = [];
|   9|   9| 
|  10|  10| AddMock(10, IID_Test, {
|  11|    |-	Callback: function(data, lateness) {
|    |  11|+	"Callback": function(data, lateness) {
|  12|  12| 		fired.push([data, lateness]);
|  13|  13| 	}
|  14|  14| });
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'Callback' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  15|  15| 
|  16|  16| var cancelId;
|  17|  17| AddMock(20, IID_Test, {
|  18|    |-	Callback: function(data, lateness) {
|    |  18|+	"Callback": function(data, lateness) {
|  19|  19| 		fired.push([data, lateness]);
|  20|  20| 		cmpTimer.CancelTimer(cancelId);
|  21|  21| 	}
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  34|  34| TS_ASSERT_UNEVAL_EQUALS(fired, []);
|  35|  35| 
|  36|  36| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  37|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]);
|    |  37|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0]]);
|  38|  38| 
|  39|  39| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  40|  40| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  37|  37| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]);
|  38|  38| 
|  39|  39| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  40|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  40|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0], ["b",300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|  43| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  37|  37| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]);
|  38|  38| 
|  39|  39| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  40|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  40|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b", 300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|  43| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  40|  40| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  43|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0], ["b",300]]);
|  44|  44| 
|  45|  45| fired = [];
|  46|  46| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  40|  40| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  43|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b", 300]]);
|  44|  44| 
|  45|  45| fired = [];
|  46|  46| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  49|  49| var e = cmpTimer.SetTimeout(10, IID_Test, "Callback", 1000, "e");
|  50|  50| cmpTimer.CancelTimer(d);
|  51|  51| cmpTimer.OnUpdate({ "turnLength": 1.0 });
|  52|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e",0]]);
|    |  52|+TS_ASSERT_UNEVAL_EQUALS(fired, [["c", 0], ["e",0]]);
|  53|  53| 
|  54|  54| fired = [];
|  55|  55| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  49|  49| var e = cmpTimer.SetTimeout(10, IID_Test, "Callback", 1000, "e");
|  50|  50| cmpTimer.CancelTimer(d);
|  51|  51| cmpTimer.OnUpdate({ "turnLength": 1.0 });
|  52|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e",0]]);
|    |  52|+TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e", 0]]);
|  53|  53| 
|  54|  54| fired = [];
|  55|  55| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  56|  56| var r = cmpTimer.SetInterval(10, IID_Test, "Callback", 500, 1000, "r");
|  57|  57| 
|  58|  58| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  59|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|    |  59|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0]]);
|  60|  60| 
|  61|  61| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  62|  62| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  59|  59| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|  60|  60| 
|  61|  61| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  62|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|    |  62|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0]]);
|  63|  63| 
|  64|  64| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  62|  62| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|  63|  63| 
|  64|  64| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  65|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|    |  65|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|  68| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  62|  62| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|  63|  63| 
|  64|  64| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  65|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|    |  65|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r", 0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|  68| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r", 0], ["r",2500], ["r",1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r", 2500], ["r",1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r", 1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r", 500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r", 0], ["r",2500], ["r",1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r", 2500], ["r",1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r", 1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r", 500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  77|  77| cancelId = cmpTimer.SetInterval(20, IID_Test, "Callback", 500, 1000, "s");
|  78|  78| 
|  79|  79| cmpTimer.OnUpdate({ "turnLength": 3.0 });
|  80|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["s",2500]]);
|    |  80|+TS_ASSERT_UNEVAL_EQUALS(fired, [["s", 2500]]);
|  81|  81| 
|  82|  82| function testUpdateRepeatTime()
|  83|  83| {
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  96|  96| 
|  97|  97| 	cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  98|  98| 	TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0], ["f", 500], ["f", 0], ["f", 0]]);
|  99|    |-};
|    |  99|+}
| 100| 100| testUpdateRepeatTime();

binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  99| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1902/display/redirect

Freagarach updated this revision to Diff 11541.Mar 24 2020, 8:28 PM

Check for timer existence.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...

binaries/data/mods/public/simulation/components/Timer.js
|  63| »   if·(typeof·repeattime·!=·"number"·||·!(repeattime·>·0))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'Callback' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|   8|   8| var fired = [];
|   9|   9| 
|  10|  10| AddMock(10, IID_Test, {
|  11|    |-	Callback: function(data, lateness) {
|    |  11|+	"Callback": function(data, lateness) {
|  12|  12| 		fired.push([data, lateness]);
|  13|  13| 	}
|  14|  14| });
|    | [NORMAL] ESLintBear (quote-props):
|    | Unquoted property 'Callback' found.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  15|  15| 
|  16|  16| var cancelId;
|  17|  17| AddMock(20, IID_Test, {
|  18|    |-	Callback: function(data, lateness) {
|    |  18|+	"Callback": function(data, lateness) {
|  19|  19| 		fired.push([data, lateness]);
|  20|  20| 		cmpTimer.CancelTimer(cancelId);
|  21|  21| 	}
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  34|  34| TS_ASSERT_UNEVAL_EQUALS(fired, []);
|  35|  35| 
|  36|  36| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  37|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]);
|    |  37|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0]]);
|  38|  38| 
|  39|  39| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  40|  40| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  37|  37| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]);
|  38|  38| 
|  39|  39| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  40|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  40|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0], ["b",300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|  43| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  37|  37| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0]]);
|  38|  38| 
|  39|  39| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  40|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  40|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b", 300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|  43| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  40|  40| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  43|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a", 0], ["b",300]]);
|  44|  44| 
|  45|  45| fired = [];
|  46|  46| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  40|  40| TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|  41|  41| 
|  42|  42| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  43|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b",300]]);
|    |  43|+TS_ASSERT_UNEVAL_EQUALS(fired, [["a",0], ["b", 300]]);
|  44|  44| 
|  45|  45| fired = [];
|  46|  46| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  49|  49| var e = cmpTimer.SetTimeout(10, IID_Test, "Callback", 1000, "e");
|  50|  50| cmpTimer.CancelTimer(d);
|  51|  51| cmpTimer.OnUpdate({ "turnLength": 1.0 });
|  52|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e",0]]);
|    |  52|+TS_ASSERT_UNEVAL_EQUALS(fired, [["c", 0], ["e",0]]);
|  53|  53| 
|  54|  54| fired = [];
|  55|  55| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  49|  49| var e = cmpTimer.SetTimeout(10, IID_Test, "Callback", 1000, "e");
|  50|  50| cmpTimer.CancelTimer(d);
|  51|  51| cmpTimer.OnUpdate({ "turnLength": 1.0 });
|  52|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e",0]]);
|    |  52|+TS_ASSERT_UNEVAL_EQUALS(fired, [["c",0], ["e", 0]]);
|  53|  53| 
|  54|  54| fired = [];
|  55|  55| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  56|  56| var r = cmpTimer.SetInterval(10, IID_Test, "Callback", 500, 1000, "r");
|  57|  57| 
|  58|  58| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  59|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|    |  59|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0]]);
|  60|  60| 
|  61|  61| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  62|  62| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  59|  59| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|  60|  60| 
|  61|  61| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  62|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|    |  62|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0]]);
|  63|  63| 
|  64|  64| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  62|  62| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|  63|  63| 
|  64|  64| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  65|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|    |  65|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|  68| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  62|  62| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0]]);
|  63|  63| 
|  64|  64| cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  65|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|    |  65|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r", 0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|  68| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r", 0], ["r",2500], ["r",1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r", 2500], ["r",1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r", 1500], ["r",500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  65|  65| TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0]]);
|  66|  66| 
|  67|  67| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  68|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  68|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r", 500]]);
|  69|  69| 
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r", 0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r", 0], ["r",2500], ["r",1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r", 2500], ["r",1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r", 1500], ["r",500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  70|  70| cmpTimer.CancelTimer(r);
|  71|  71| 
|  72|  72| cmpTimer.OnUpdate({ "turnLength": 3.5 });
|  73|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r",500]]);
|    |  73|+TS_ASSERT_UNEVAL_EQUALS(fired, [["r",0], ["r",0], ["r",2500], ["r",1500], ["r", 500]]);
|  74|  74| 
|  75|  75| fired = [];
|  76|  76| 
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  77|  77| cancelId = cmpTimer.SetInterval(20, IID_Test, "Callback", 500, 1000, "s");
|  78|  78| 
|  79|  79| cmpTimer.OnUpdate({ "turnLength": 3.0 });
|  80|    |-TS_ASSERT_UNEVAL_EQUALS(fired, [["s",2500]]);
|    |  80|+TS_ASSERT_UNEVAL_EQUALS(fired, [["s", 2500]]);
|  81|  81| 
|  82|  82| function testUpdateRepeatTime()
|  83|  83| {
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  96|  96| 
|  97|  97| 	cmpTimer.OnUpdate({ "turnLength": 0.5 });
|  98|  98| 	TS_ASSERT_UNEVAL_EQUALS(fired, [["f", 0], ["f", 0], ["f", 500], ["f", 0], ["f", 0]]);
|  99|    |-};
|    |  99|+}
| 100| 100| testUpdateRepeatTime();

binaries/data/mods/public/simulation/components/tests/test_Timer.js
|  99| };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1903/display/redirect

Freagarach added inline comments.Mar 24 2020, 9:11 PM
binaries/data/mods/public/simulation/components/Timer.js
95 ↗(On Diff #11541)

We could correct for the difference in repeat time?

bb accepted this revision as: bb.May 19 2020, 5:41 PM
bb removed a reviewer: Restricted Owners Package.
bb added a subscriber: bb.
bb added inline comments.
binaries/data/mods/public/simulation/components/tests/test_Timer.js
82 ↗(On Diff #11541)

No need for function

95 ↗(On Diff #11541)

Adding a comment why this is actually correct.

This revision is now accepted and ready to land.May 19 2020, 5:41 PM
This revision was automatically updated to reflect the committed changes.

Thanks for the review and commit @bb!