Exemple #1
0
 def test_or_and(self):
     assert plural._Parser('n = 0 or n != 1 and n % 100 = 1..19').ast == \
         ('or', (self.n_eq(0),
                 ('and', (plural.negate(self.n_eq(1)),
                          ('relation', ('in',
                                        ('mod', (self.n,
                                                 plural.value_node(100))),
                                        (make_range_list((1, 19)))))))
                 ))
Exemple #2
0
 def test_or_and(self):
     assert plural._Parser('n = 0 or n != 1 and n % 100 = 1..19').ast == \
         ('or', (self.n_eq(0),
                 ('and', (plural.negate(self.n_eq(1)),
                          ('relation', ('in',
                                        ('mod', (self.n,
                                                 plural.value_node(100))),
                                        (make_range_list((1, 19)))))))
                 ))
Exemple #3
0
 def test_and(self):
     assert plural._Parser('n = 1 and n = 2').ast ==\
         ('and', (self.n_eq(1), self.n_eq(2)))
Exemple #4
0
 def test_or(self):
     assert plural._Parser('n = 1 or n = 2').ast ==\
         ('or', (self.n_eq(1), self.n_eq(2)))
Exemple #5
0
 def test_negate(self):
     assert plural._Parser('n != 1').ast == plural.negate(self.n_eq(1))
Exemple #6
0
 def test_in_range_relation(self):
     assert plural._Parser('n = 2..4').ast == \
         ('relation', ('in', self.n, make_range_list((2, 4))))
Exemple #7
0
 def test_eq_relation(self):
     assert plural._Parser('n = 1').ast == self.n_eq(1)
Exemple #8
0
 def test_error_when_unexpected_end(self):
     with pytest.raises(plural.RuleError):
         plural._Parser('n =')
Exemple #9
0
 def test_and(self):
     assert plural._Parser('n = 1 and n = 2').ast ==\
         ('and', (self.n_eq(1), self.n_eq(2)))
Exemple #10
0
 def test_or(self):
     assert plural._Parser('n = 1 or n = 2').ast ==\
         ('or', (self.n_eq(1), self.n_eq(2)))
Exemple #11
0
 def test_negate(self):
     assert plural._Parser('n != 1').ast == plural.negate(self.n_eq(1))
Exemple #12
0
 def test_in_range_relation(self):
     assert plural._Parser('n = 2..4').ast == \
         ('relation', ('in', self.n, make_range_list((2, 4))))
Exemple #13
0
 def test_eq_relation(self):
     assert plural._Parser('n = 1').ast == self.n_eq(1)
Exemple #14
0
 def test_error_when_unexpected_end(self):
     with pytest.raises(plural.RuleError):
         plural._Parser('n =')