Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/tests/test_DiskPlacer.js
- This file was added.
Engine.LoadLibrary("rmgen"); | |||||
var g_MapSettings = { "Size": 512 }; | |||||
var g_Map = new RandomMap(0, 0, "blackness"); | |||||
{ | |||||
let center = new Vector2D(10, 10); | |||||
let area = createArea(new DiskPlacer(3, center)); | |||||
// contains center | |||||
TS_ASSERT(area.contains(new Vector2D(10, 10))); | |||||
Stan: Small nitpick, comments should start with capitals. | |||||
Done Inline Actionsmaybe use the center variable? Stan: maybe use the center variable? | |||||
// contains disk boundaries | |||||
TS_ASSERT(area.contains(new Vector2D(10, 13))); | |||||
TS_ASSERT(area.contains(new Vector2D(10, 7))); | |||||
TS_ASSERT(area.contains(new Vector2D(7, 10))); | |||||
TS_ASSERT(area.contains(new Vector2D(13, 10))); | |||||
// does not contain rectangle vertices | |||||
TS_ASSERT(!area.contains(new Vector2D(13, 13))); | |||||
TS_ASSERT(!area.contains(new Vector2D(7, 7))); | |||||
TS_ASSERT(!area.contains(new Vector2D(13, 7))); | |||||
TS_ASSERT(!area.contains(new Vector2D(7, 13))); | |||||
// does not contain points outside disk range | |||||
TS_ASSERT(!area.contains(new Vector2D(10, 14))); | |||||
TS_ASSERT(!area.contains(new Vector2D(10, 6))); | |||||
TS_ASSERT(!area.contains(new Vector2D(6, 10))); | |||||
TS_ASSERT(!area.contains(new Vector2D(14, 10))); | |||||
area = createArea(new DiskPlacer(3, new Vector2D(0, 0))); | |||||
Done Inline ActionsMaybe you can omit 0,0 From binaries/data/mods/public/globalscripts/vector.js function Vector2D(x = 0, y = 0) { this.set(x, y); } Stan: Maybe you can omit 0,0
From binaries/data/mods/public/globalscripts/vector.js
```lang=js… | |||||
Done Inline ActionsI prefer to have it explicit for the tests badosu: I prefer to have it explicit for the tests | |||||
TS_ASSERT(!area.contains(new Vector2D(-1, 0))); // does not allow points out of map boundaries | |||||
TS_ASSERT(area.contains(new Vector2D(0, 0))); // contains center on map edge | |||||
} | |||||
Done Inline ActionsComments on top rather than at the end of the lines. Stan: Comments on top rather than at the end of the lines. | |||||
Done Inline ActionsRegression test for floating point radius, I am reproducing the exact issue I found testing gear badosu: Regression test for floating point radius, I am reproducing the exact issue I found testing gear | |||||
Done Inline ActionsAnother regression test to avoid cache access on map size index badosu: Another regression test to avoid cache access on map size index | |||||
Done Inline Actions(One could also split the tests into separate scopes, so it becomes a bit more clear where one test ends and the next one starts, which locals they use. Also scopes imply deletion of previous values which can, in general, make the test safer or more explicit since it rules out that some values carry over unintentionally) elexis: (One could also split the tests into separate scopes, so it becomes a bit more clear where one… |
Wildfire Games · Phabricator
Small nitpick, comments should start with capitals.