Ticket #4263: test_technologies.js

File test_technologies.js, 3.8 KB (added by fatherbushido, 7 years ago)
Line 
1// TODO: Move that in another folder
2
3let template ={};
4
5TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), []);
6
7template.requirements = { "all": [{ "entity": { "class": "Village", "number": 5 } }, { "civ": "athen" }] };
8TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ entities: [{ class:"Village", number:5, check:"count" }] }]);
9TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "spart"), false);
10
11template.requirements = { "all": [{ "entity": { "class": "Village", "numberOfTypes": 5 } }, { "civ": "athen" }] };
12TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ entities:[{ class:"Village", number:5, check:"variants" }] }]);
13TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "spart"), false);
14
15template.requirements = { "all": [{ "tech": "phase_town" }, { "notciv": "maur" }, { "notciv": "spart" }] };
16TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ "techs": ["phase_town"] }]);
17
18template.requirements = { "all": [{ "tech": "phase_town" }, { "all": [{ "notciv": "maur" }, { "notciv": "spart" }] }] };
19TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), [{ "techs": ["phase_town"] }]);
20
21template.requirements = { "all": [{ "entity": { "class": "Village", "numberOfTypes": 5 } }, { "entity": { "class": "Melee", "number": 6 } }, { "civ": "athen" }] };
22TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"),
23[{ entities: [{ class:"Village", number:5, check:"variants" }, { class:"Melee", number:6, check:"count" }] } ]);
24
25template.requirements = { "all": [{ "tech": "phase_city" }, { "any": [{ "civ": "brit"}, { "civ": "gaul"}, { "civ": "iber"}, { "civ": "mace"}, { "civ": "maur" }, { "civ": "rome" }] }] };
26TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"), false);
27TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "brit"), [{ "techs": ["phase_city"] }]);
28
29template.requirements =
30{ "all": [{ "any":[{ "entity": { "class": "Village", "numberOfTypes": 5 } },
31 { "entity": { "class": "Melee", "number": 6 } }] }, { "civ": "athen" }] };
32TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "athen"),
33 [{ "entities" : [{ class:"Village", "number":5, "check":"variants" }] }, { "entities": [{ class: "Melee", "number": 6, "check": "count" }] }]);
34
35template.requirements =
36{ "all": [{ "tech": "tech1" }, { "any": [{ "civ": "civA" }, { "civ": "civB" }]}, { "notciv": "civC" }] };
37TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]);
38TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), false);
39
40template.requirements =
41{ "any": [{ "all": [{ "civ": "civA" }, { "tech": "tech1" }] }, { "tech": "tech2" }] };
42TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }, { "techs": ["tech2"] }]);
43TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civB"), [{ "techs": ["tech2"] }]);
44
45template.requirements =
46{ "any": [{ "all": [{ "civ": "civA" }, { "tech": "tech1" }] }, { "all": [{ "civ": "civB" }, { "tech": "tech2" }] }] };
47TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]);
48TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civB"), [{ "techs": ["tech2"] }]);
49TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), false);
50
51template.requirements =
52{ "any": [{ "all": [{ "civ": "civA" }, { "tech": "tech1" }] }, { "all": [{ "any": [{ "civ": "civB" }, { "civ": "civC" }] }, { "tech": "tech2" }] }] };
53TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civA"), [{ "techs": ["tech1"] }]);
54TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civC"), [{ "techs": ["tech2"] }]);
55TS_ASSERT_UNEVAL_EQUALS(DeriveTechnologyRequirements(template, "civD"), false);