]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130193: Increase test coverage of gettext.c2py (GH-130208)
authorTomas R. <tomas.roun8@gmail.com>
Mon, 17 Feb 2025 08:57:34 +0000 (09:57 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2025 08:57:34 +0000 (10:57 +0200)
Lib/test/test_gettext.py

index dd00e8498962fe156b7b93d39e2ac859cb2077e5..cddd859001d81854113195c785197caf91dd3491 100644 (file)
@@ -517,12 +517,18 @@ class PluralFormsInternalTestCase(unittest.TestCase):
     def test_invalid_syntax(self):
         invalid_expressions = [
             'x>1', '(n>1', 'n>1)', '42**42**42', '0xa', '1.0', '1e2',
-            'n>0x1', '+n', '-n', 'n()', 'n(1)', '1+', 'nn', 'n n',
+            'n>0x1', '+n', '-n', 'n()', 'n(1)', '1+', 'nn', 'n n', 'n ? 1 2'
         ]
         for expr in invalid_expressions:
             with self.assertRaises(ValueError):
                 gettext.c2py(expr)
 
+    def test_negation(self):
+        f = gettext.c2py('!!!n')
+        self.assertEqual(f(0), 1)
+        self.assertEqual(f(1), 0)
+        self.assertEqual(f(2), 0)
+
     def test_nested_condition_operator(self):
         self.assertEqual(gettext.c2py('n?1?2:3:4')(0), 4)
         self.assertEqual(gettext.c2py('n?1?2:3:4')(1), 2)