to the power of precedences

This commit is contained in:
Dave Halter
2014-03-08 03:05:38 +01:00
parent 0a253b4651
commit 3559dba7ea
2 changed files with 13 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ def parse_tree(statement_string):
def test_simple():
assert parse_tree('1+2') == (1, '+', 2)
assert parse_tree('+2') == (None, '+', 2)
assert parse_tree('1+2-3') == ((1, '+', 2), '-', 3)
def test_prefixed():
@@ -38,8 +39,15 @@ def test_invalid():
assert parse_tree('1 not - 1') == (1, '-', 1)
assert parse_tree('1 - not ~1') == (1, '-', (None, '~', 1))
# not not allowed
assert parse_tree('1 is not not 1') == (1, 'is not', 1)
def test_multi_part():
assert parse_tree('1 not in 2') == (1, 'not in', 2)
assert parse_tree('1 is not -1') == (1, 'is not', (None, '-', 1))
assert parse_tree('1 is 1') == (1, 'is', 1)
def test_power():
assert parse_tree('2 ** 3 ** 4') == (2, '**', (3, '**', 4))