Skip to content

Commit

Permalink
tests/test_parsing_expressions: fix specific assert statements
Browse files Browse the repository at this point in the history
I apologize for the fast coding yesterday. I marked with "FIXME" some of the
tests incorrectly.
  • Loading branch information
stanislaw committed Apr 8, 2023
1 parent 7523102 commit c73d6aa
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions arpeggio/tests/test_parsing_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ def grammar():
"Expected 'b' at position (1, 4) => 'a c*'."
) == str(e.value)

# FIXME: This test looks strange. The expectation would rather be:
# Expected 'a' or 'c' at position (1, 3)
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("b b a c")
assert (
"Expected 'b' at position (1, 4) => 'b b* a c'."
"Expected 'a' or 'c' at position (1, 3) => 'b *b a c'."
) == str(e.value)


Expand Down Expand Up @@ -188,11 +186,11 @@ def grammar():
"Expected EOF at position (1, 8) => 'a, b, c*, b'."
) == str(e.value)

# FIXME: This looks strange. Shouldn't this expect ',' (and also 'c')?
with pytest.raises(NoMatch):
# FIXME: Shouldn't this only be ',' and the position 5?
with pytest.raises(NoMatch) as e:
parser.parse("a, b ")
assert (
"Expected EOF at position (1, 8) => 'a, b *'."
"Expected ',' or 'c' at position (1, 6) => 'a, b *'."
) == str(e.value)

with pytest.raises(NoMatch) as e:
Expand All @@ -201,18 +199,17 @@ def grammar():
"Expected 'b' at position (1, 7) => 'a, c, *'."
) == str(e.value)

# FIXME: This looks strange. Shouldn't be ',' at position 6?
with pytest.raises(NoMatch):
# FIXME: Shouldn't the ',' be at position 5?
with pytest.raises(NoMatch) as e:
parser.parse("a, b c ")
assert (
"Expected 'b' at position (1, 7) => 'a, b c* '."
"Expected ',' at position (1, 6) => 'a, b *c '."
) == str(e.value)

# FIXME: Should the separators work before the unordered group?
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse(",a, c ")
assert (
"Expected 'b' at position (1, 7) => ',a, c *'."
"Expected 'a' or 'b' or 'c' at position (1, 1) => '*,a, c '."
) == str(e.value)


Expand Down Expand Up @@ -268,26 +265,22 @@ def grammar():
"Expected ',' or EOF at position (1, 2) => 'a*a a'."
) == str(e.value)

# FIXME: This looks strange. Can separator be before the first element?
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse(",a,a ,a")
assert (
"Expected ',' or EOF at position (1, 2) => ',*a,a ,a'."
"Expected 'a' or EOF at position (1, 1) => '*,a,a ,a'."
) == str(e.value)

# FIXME: The position looks strange.
# Should this be 'a' or 'EOF' at the position of the last comma?
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("a,a ,a,")
assert (
"Expected ',' or EOF at position (1, 2) => 'a*,a ,a,'."
"Expected 'a' at position (1, 8) => 'a,a ,a,*'."
) == str(e.value)

# FIXME: Shouldn't this be 'a' or 'EOF' at (1, 1)?
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("bbb")
assert (
"Expected ',' or EOF at position (1, 2) => 'b*bb'."
"Expected 'a' or EOF at position (1, 1) => '*bbb'."
) == str(e.value)


Expand Down Expand Up @@ -354,7 +347,7 @@ def grammar():
"Expected 'a' at position (1, 1) => '*'."
) == str(e.value)

with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("b")
assert (
"Expected 'a' at position (1, 1) => '*b'."
Expand Down Expand Up @@ -383,27 +376,25 @@ def grammar():
"Expected 'a' at position (1, 1) => '*'."
) == str(e.value)

with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("b")
assert (
"Expected 'a' at position (1, 1) => '*b'."
) == str(e.value)

# FIXME: Should it be like this? Or ',' at (1, 2)?
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("a a b")
assert (
"Expected 'a' at position (1, 1) => '*a a b'."
"Expected ',' or 'b' at position (1, 3) => 'a *a b'."
) == str(e.value)

# FIXME: Should it be like this? Or ',' at (1, 2)?
with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse("a a, b")
assert (
"Expected 'a' at position (1, 1) => '*a a, b'."
"Expected ',' or 'b' at position (1, 3) => 'a *a, b'."
) == str(e.value)

with pytest.raises(NoMatch):
with pytest.raises(NoMatch) as e:
parser.parse(", a, a b")
assert (
"Expected 'a' at position (1, 1) => '*, a, a b'."
Expand Down

0 comments on commit c73d6aa

Please sign in to comment.