← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/test-ngettext into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/test-ngettext into lp:widelands.

Commit message:
Created test for lua gettext functions.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/test-ngettext/+merge/291587

We missed fixing ngettext when updating eris, so I've created a test.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/test-ngettext into lp:widelands.
=== added file 'test/maps/lua_testsuite.wmf/scripting/gettext.lua'
--- test/maps/lua_testsuite.wmf/scripting/gettext.lua	1970-01-01 00:00:00 +0000
+++ test/maps/lua_testsuite.wmf/scripting/gettext.lua	2016-04-12 07:40:22 +0000
@@ -0,0 +1,26 @@
+test_descr = lunit.TestCase("Gettext Test")
+
+--  Since we run the test suite in English, this will only test
+--  whether gettext functions crash or not
+
+function test_descr:test_gettext()
+   set_textdomain("tribes")
+   assert_equal("foo", _"foo")
+   assert_equal("foo", _("foo"))
+   assert_equal(_"Carrier", _("Carrier"))
+end
+
+function test_descr:test_ngettext()
+   assert_equal("foo", ngettext("foo", "bar", 1))
+   -- TODO(GunChleoc): Just using the floor here is wrong for English,
+   -- but an edge case as compared to other languages that need it here.
+   -- ngettext doesn't actually support floating point numbers,
+   -- so we might want to create our own rules off the CLDR some time.
+   assert_equal("foo", ngettext("foo", "bar", 1.5))
+   assert_equal("bar", ngettext("foo", "bar", 1000))
+   assert_equal("bar", ngettext("foo", "bar", 1000.5))
+end
+
+function test_descr:test_pgettext()
+   assert_equal("bar", pgettext("foo", "bar"))
+end

=== modified file 'test/maps/lua_testsuite.wmf/scripting/init.lua'
--- test/maps/lua_testsuite.wmf/scripting/init.lua	2016-01-25 18:50:54 +0000
+++ test/maps/lua_testsuite.wmf/scripting/init.lua	2016-04-12 07:40:22 +0000
@@ -23,6 +23,7 @@
 -- =================================
 include "map:scripting/egbase.lua"
 
+include "map:scripting/gettext.lua"
 include "map:scripting/math_random.lua"
 include "map:scripting/string_bformat.lua"
 include "map:scripting/path.lua"


Follow ups