From 30afd11e4effccd3d517bedc62f8cfdad4623ae2 Mon Sep 17 00:00:00 2001 From: Alex Morega Date: Sat, 6 Jul 2013 15:03:29 +0200 Subject: test for range pluralization https://gist.github.com/mitsuhiko/5939731 --- tests/test_plural.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/test_plural.py') diff --git a/tests/test_plural.py b/tests/test_plural.py index 644a97d..89a782b 100644 --- a/tests/test_plural.py +++ b/tests/test_plural.py @@ -68,3 +68,25 @@ def test_cldr_modulo(): assert plural.cldr_modulo(-3, 5) == -3 assert plural.cldr_modulo(-3, -5) == -3 assert plural.cldr_modulo(3, 5) == 3 + + +def test_plural_within_rules(): + p = plural.PluralRule({'one': 'n is 1', 'few': 'n within 2,4,7..9'}) + assert repr(p) == "" + assert plural.to_javascript(p) == ( + "(function(n) { " + "return ((n == 2) || (n == 4) || (n >= 7 && n <= 9))" + " ? 'few' : (n == 1) ? 'one' : 'other'; })") + assert plural.to_gettext(p) == ( + 'nplurals=3; plural=(((n == 2) || (n == 4) || (n >= 7 && n <= 9))' + ' ? 1 : (n == 1) ? 0 : 2)') + assert p(0) == 'other' + assert p(1) == 'one' + assert p(2) == 'few' + assert p(3) == 'other' + assert p(4) == 'few' + assert p(5) == 'other' + assert p(6) == 'other' + assert p(7) == 'few' + assert p(8) == 'few' + assert p(9) == 'few' -- cgit v1.2.1