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))))))) ))
def test_and(self): assert plural._Parser('n = 1 and n = 2').ast ==\ ('and', (self.n_eq(1), self.n_eq(2)))
def test_or(self): assert plural._Parser('n = 1 or n = 2').ast ==\ ('or', (self.n_eq(1), self.n_eq(2)))
def test_negate(self): assert plural._Parser('n != 1').ast == plural.negate(self.n_eq(1))
def test_in_range_relation(self): assert plural._Parser('n = 2..4').ast == \ ('relation', ('in', self.n, make_range_list((2, 4))))
def test_eq_relation(self): assert plural._Parser('n = 1').ast == self.n_eq(1)
def test_error_when_unexpected_end(self): with pytest.raises(plural.RuleError): plural._Parser('n =')