Merge pull request #96 from badgerman/bug-1882

functional tests for orders with more than one name
This commit is contained in:
Enno Rehling 2015-01-04 15:48:45 +01:00
commit eb5c912805
9 changed files with 62 additions and 16 deletions

View File

@ -1,6 +1,7 @@
{ {
"keywords": { "keywords": {
"en" : { "en" : {
"grow": [ "GROW", "BREED", "PLANT" ],
"combat": [ "COMBAT", "FIGHT" ] "combat": [ "COMBAT", "FIGHT" ]
}, },
"de": { "de": {
@ -51,7 +52,7 @@
"cast": ["ZAUBERE", "ZAUBERN"], "cast": ["ZAUBERE", "ZAUBERN"],
"show": ["ZEIGE", "ZEIGEN"], "show": ["ZEIGE", "ZEIGEN"],
"destroy": ["ZERSTÖRE", "ZERSTÖREN"], "destroy": ["ZERSTÖRE", "ZERSTÖREN"],
"grow": ["ZÜCHTE", "ZÜCHTEN"], "grow": ["ZÜCHTE", "PFLANZE", "ZÜCHTEN", "PFLANZEN"],
"default": "DEFAULT", "default": "DEFAULT",
"origin": "URSPRUNG", "origin": "URSPRUNG",
"email": "EMAIL", "email": "EMAIL",
@ -59,7 +60,6 @@
"group": "GRUPPE", "group": "GRUPPE",
"sort": ["SORTIERE", "SORTIEREN"], "sort": ["SORTIERE", "SORTIEREN"],
"prefix": "PRÄFIX", "prefix": "PRÄFIX",
"plant": ["PFLANZE", "PFLANZEN"],
"alliance": "ALLIANZ", "alliance": "ALLIANZ",
"claim": ["BEANSPRUCHE", "BEANSPRUCHEN"], "claim": ["BEANSPRUCHE", "BEANSPRUCHEN"],
"promote": ["BEFÖRDERE", "BEFÖRDERUNG"], "promote": ["BEFÖRDERE", "BEFÖRDERUNG"],

View File

@ -1496,9 +1496,6 @@
<string name="pay"> <string name="pay">
<text locale="en">PAY</text> <text locale="en">PAY</text>
</string> </string>
<string name="plant">
<text locale="en">PLANT</text>
</string>
<string name="piracy"> <string name="piracy">
<text locale="en">PIRACY</text> <text locale="en">PIRACY</text>
</string> </string>
@ -1568,9 +1565,6 @@
<string name="destroy"> <string name="destroy">
<text locale="en">DESTROY</text> <text locale="en">DESTROY</text>
</string> </string>
<string name="grow">
<text locale="en">GROW</text>
</string>
<string name="loot"> <string name="loot">
<text locale="en">loot</text> <text locale="en">loot</text>
</string> </string>

View File

@ -2,3 +2,4 @@ require 'tests.e3.castles'
require 'tests.e3.stealth' require 'tests.e3.stealth'
require 'tests.e3.spells' require 'tests.e3.spells'
require 'tests.e3.rules' require 'tests.e3.rules'
require 'tests.e3.parser'

View File

@ -0,0 +1,57 @@
require 'lunit'
module('tests.e3.parser', package.seeall, lunit.testcase)
function setup()
eressea.game.reset()
end
function test_set_status_en()
local r = region.create(0, 0, "plain")
local f = faction.create("bug_1882@eressea.de", "human", "en")
local u = unit.create(f, r, 1)
u.status = 1
u:clear_orders()
u:add_order("COMBAT AGGRESSIVE")
process_orders()
assert_equal(u.status, 0)
u.status = 1
u:add_order("FIGHT AGGRESSIVE")
process_orders()
assert_equal(u.status, 0)
end
function test_set_status_de()
local r = region.create(0, 0, "plain")
local f = faction.create("bug_1882@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.status = 1
u:clear_orders()
u:add_order("KAEMPFE AGGRESSIV")
process_orders()
assert_equal(u.status, 0)
end
function test_breed_horses()
local r = region.create(0, 0, "plain")
local f = faction.create("bug_1886@eressea.de", "human", "en")
local u = unit.create(f, r, 1)
local b = building.create(r, "stables")
b.size = 10
u.building = b
u:add_item("horse", 2)
u:add_item("money", 2000)
u:set_skill("training", 100) -- 100% chance to duplicate each horse
u:clear_orders()
u:add_order("GROW horses")
process_orders()
assert_equal(4, u:get_item("horse"))
u:clear_orders()
u:add_order("BREED horses")
process_orders()
assert_equal(8, u:get_item("horse"))
u:clear_orders()
u:add_order("PLANT horses")
process_orders()
assert_equal(16, u:get_item("horse"))
end

View File

@ -3270,7 +3270,6 @@ void produce(struct region *r)
sabotage_cmd(u, u->thisorder); sabotage_cmd(u, u->thisorder);
break; break;
case K_PLANT:
case K_BREED: case K_BREED:
breed_cmd(u, u->thisorder); breed_cmd(u, u->thisorder);
break; break;

View File

@ -408,7 +408,6 @@ bool is_repeated(const order * ord)
case K_TEACH: case K_TEACH:
case K_BREED: case K_BREED:
case K_PIRACY: case K_PIRACY:
case K_PLANT:
case K_MAKE: case K_MAKE:
case K_LOOT: case K_LOOT:
case K_DESTROY: case K_DESTROY:
@ -450,7 +449,6 @@ bool is_exclusive(const order * ord)
case K_TEACH: case K_TEACH:
case K_BREED: case K_BREED:
case K_PIRACY: case K_PIRACY:
case K_PLANT:
case K_MAKE: case K_MAKE:
case K_LOOT: case K_LOOT:
case K_DESTROY: case K_DESTROY:
@ -495,7 +493,6 @@ bool is_long(const order * ord)
case K_TEACH: case K_TEACH:
case K_BREED: case K_BREED:
case K_PIRACY: case K_PIRACY:
case K_PLANT:
case K_MAKE: case K_MAKE:
case K_LOOT: case K_LOOT:
case K_DESTROY: case K_DESTROY:

View File

@ -168,8 +168,9 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
if (s[0]) { if (s[0]) {
if (s[0] != '@') { if (s[0] != '@') {
char token[128];
const char *stok = s; const char *stok = s;
stok = parse_token_depr(&stok); stok = parse_token(&stok, token, sizeof(token));
if (stok) { if (stok) {
bool quit = false; bool quit = false;
@ -192,7 +193,6 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
} }
break; break;
default: default:
/* TODO: syntax error message */
break; break;
} }
if (quit) { if (quit) {

View File

@ -138,7 +138,6 @@ const char *keywords[MAXKEYWORDS] = {
"group", "group",
"sort", "sort",
"prefix", "prefix",
"plant",
"alliance", "alliance",
"claim", "claim",
"promote", "promote",

View File

@ -64,7 +64,6 @@ typedef enum {
K_GROUP, K_GROUP,
K_SORT, K_SORT,
K_PREFIX, K_PREFIX,
K_PLANT,
K_ALLIANCE, K_ALLIANCE,
K_CLAIM, K_CLAIM,
K_PROMOTION, K_PROMOTION,