Page MenuHomeWildfire Games

Few random random map script unit tests
ClosedPublic

Authored by elexis on Jan 29 2020, 3:27 PM.

Details

Summary

This diff adds some more initial test cases to document the current behavior of the code.
This way, classes using wrong math like TileClass will have their bugs documented in test cases.

Test Plan

Notice there is little test coverage and consider which cases would be most interesting or necessary to add next.
(Eventually there should be unit tests for every rmgen class.)

One can check the correctness (or reproduce the incorrectness of numbers) using the new_rms_test map and printing the areas and visually confirming that the area is what is intended.
The TileClass numbers themselves are known to be wrong (refs infamous '#27' algorithm difference in TileClass.js)

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

elexis created this revision.Jan 29 2020, 3:27 PM

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

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

elexis updated this revision to Diff 11217.Jan 29 2020, 6:50 PM

Missing test setup file

elexis updated this revision to Diff 11218.Jan 29 2020, 6:51 PM

Missing test/ files -.-

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (new-parens):
|    | Missing '()' invoking a constructor.
|----|    | /zpool0/trunk/binaries/data/tests/test_setup.js
|    |++++| /zpool0/trunk/binaries/data/tests/test_setup.js
|   8|   8| function fail(msg)
|   9|   9| {
|  10|  10| 	// Get a list of callers
|  11|    |-	let trace = (new Error).stack.split("\n");
|    |  11|+	let trace = (new Error()).stack.split("\n");
|  12|  12| 	// Remove the Error ctor and this function from the stack
|  13|  13| 	trace = trace.splice(2);
|  14|  14| 	trace = "Stack trace:\n" + trace.join("\n");

binaries/data/tests/test_setup.js
|  54| »   }·catch·(e)·{
|    | [NORMAL] ESLintBear (no-empty):
|    | Empty block statement.

binaries/data/tests/test_setup.js
|  11| »   let·trace·=·(new·Error).stack.split("\n");
|    | [NORMAL] JSHintBear:
|    | Missing '()' invoking a constructor.

binaries/data/tests/test_setup.js
|  31| »   if·(!(x·===·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  45| »   if·(!(uneval(x)·===·uneval(y)))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  66| »   if·(!(x·<·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  72| »   if·(!(x·>·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  78| »   if·(!(x·<=·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  84| »   if·(!(x·>=·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.
Executing section cli...

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

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (new-parens):
|    | Missing '()' invoking a constructor.
|----|    | /zpool0/trunk/binaries/data/tests/test_setup.js
|    |++++| /zpool0/trunk/binaries/data/tests/test_setup.js
|   8|   8| function fail(msg)
|   9|   9| {
|  10|  10| 	// Get a list of callers
|  11|    |-	let trace = (new Error).stack.split("\n");
|    |  11|+	let trace = (new Error()).stack.split("\n");
|  12|  12| 	// Remove the Error ctor and this function from the stack
|  13|  13| 	trace = trace.splice(2);
|  14|  14| 	trace = "Stack trace:\n" + trace.join("\n");

binaries/data/tests/test_setup.js
|  54| »   }·catch·(e)·{
|    | [NORMAL] ESLintBear (no-empty):
|    | Empty block statement.

binaries/data/tests/test_setup.js
|  11| »   let·trace·=·(new·Error).stack.split("\n");
|    | [NORMAL] JSHintBear:
|    | Missing '()' invoking a constructor.

binaries/data/tests/test_setup.js
|  31| »   if·(!(x·===·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  45| »   if·(!(uneval(x)·===·uneval(y)))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  66| »   if·(!(x·<·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  72| »   if·(!(x·>·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  78| »   if·(!(x·<=·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.

binaries/data/tests/test_setup.js
|  84| »   if·(!(x·>=·y))
|    | [NORMAL] JSHintBear:
|    | Confusing use of '!'.
Executing section cli...

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

This revision was not accepted when it landed; it landed in state Needs Review.Jan 29 2020, 7:52 PM
This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Jan 29 2020, 7:52 PM