Fix test for parser construction
@@ -192,13 +192,25 @@ def test_prefer_shifts_no_sr_conflicts():
assert result == output
# GLR parser can parse without prefer_shifts strategy. This grammar is
- # ambiguous but, in this case, implicit elimination of empty trees (due to
- # optional "b") will yield a single result.
+ # ambiguous and yields 11 solutions for the given input.
parser = GLRParser(g)
- result = parser.parse(input_str)
- assert len(result) == 1
- assert result[0] == output
-
+ results = parser.parse(input_str)
+ expected = [
+ [['b', ['a']], [None, ['a']], [None, ['a']], ['b', ['a', 'a']]],
+ [['b', ['a', 'a']], [None, ['a']], ['b', ['a', 'a']]],
+ [['b', ['a', 'a', 'a']], ['b', ['a', 'a']]],
+ [['b', ['a']], [None, ['a', 'a']], ['b', ['a', 'a']]],
+ [['b', ['a']], [None, ['a', 'a']], ['b', ['a']], [None, ['a']]],
+ [['b', ['a', 'a', 'a']], ['b', ['a']], [None, ['a']]],
+ [['b', ['a', 'a']], [None, ['a']], ['b', ['a']], [None, ['a']]],
+ [['b', ['a']], [None, ['a', 'a']], ['b', ['a']], [None, ['a']]],
+ [['b', ['a', 'a', 'a']], ['b', ['a']], [None, ['a']]],
+ [['b', ['a', 'a']], [None, ['a']], ['b', ['a']], [None, ['a']]],
+ [['b', ['a']], [None, ['a']], [None, ['a']], ['b', ['a']], [None, ['a']]] # noqa
+ ]
+ assert results == expected
+
+ # But if `prefer_shift` is used we get only one solution
parser = GLRParser(g, prefer_shifts=True)
result = parser.parse(input_str)
assert len(result) == 1
