Skip to content

Commit

Permalink
Improve unit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lhelwerd committed Oct 5, 2017
1 parent cbbf783 commit 99f1a54
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ def test_notin(self):

self.assertTrue(self.parser.parse('0 not in data'))

def test_ifelse(self):
"""
Test the 'if..else' inline conditional expression.
"""

self.assertEqual(self.parser.parse('0 if True else 1'), 0)
self.assertEqual(self.parser.parse('0.5 if 1 > 2 else 1.5'), 1.5)

def test_variables(self):
"""
Test whether known variables work and whether undefined variables raise
Expand Down Expand Up @@ -295,3 +303,18 @@ def test_functions(self):

with self.assertRaisesError("Star arguments are not supported"):
parser.parse('x2(1, *data)')

def test_disallowed(self):
"""
Test whether disallowed syntax, such as control structures, raise
exceptions.
"""

with self.assertRaisesError("Node .* not allowed"):
self.parser.parse('while True: pass')

with self.assertRaisesError("Exactly one expression must be provided"):
self.parser.parse('')

with self.assertRaisesError("Exactly one expression must be provided"):
self.parser.parse('1;2')

0 comments on commit 99f1a54

Please sign in to comment.