From 767ef13722f8a562b0c426fbcc0b4b59fb654f35 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 12 Sep 2015 12:05:38 +0200 Subject: [PATCH] add a functional test for prefixes in E2 before refactoring any of that code. --- scripts/tests/e2/e2features.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index f5e40d42a..a80e6390e 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -335,3 +335,29 @@ function test_stonegolems() assert_equal(1 ,u2.number, "There shoud be one Stone Golems") -- end test Stone Golems four stones end + +local function set_order(u, str) + u:clear_orders() + u:add_order(str) +end + +function test_prefix() + local r0 = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r0, 1) + + set_order(u1, "PRAEFIX See") + process_orders() + assert_not_nil(u1:show():find("Seemensch")) + + u1.race = "elf" + assert_not_nil(u1:show():find("Seeelf")) + + set_order(u1, "PRAEFIX Mond") + process_orders() + assert_not_nil(u1:show():find("Mondelf")) + + set_order(u1, "PRAEFIX") + process_orders() + assert_not_nil(u1:show():find("Elf")) +end