diff --git a/src/parse.py b/src/parse.py index 29039ee..47b815d 100644 --- a/src/parse.py +++ b/src/parse.py @@ -27,9 +27,9 @@ def __eq__(self, other): return ( - self.value == other.value + self.type == other.type + and self.value == other.value and self.location == other.location - and self.type == other.type ) diff --git a/tests/test_parse.py b/tests/test_parse.py index 88c991d..79c69de 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -30,10 +30,23 @@ return parse.Syntax(value, location, type) +# Draws a text syntax value +@composite +def draw_syntax_text(draw): + value = draw(text()) + location = draw(draw_syntax_location()) + type = parse.SyntaxType.TEXT + return parse.Syntax(value, location, type) + + # Draws a random syntax @composite def draw_syntax_random(draw): - return draw(draw_syntax_token()) + strategies = [ + draw_syntax_token(), + draw_syntax_text(), + ] + return draw(one_of(strategies)) # Test syntax getters @@ -50,9 +63,9 @@ @given(draw_syntax_random(), draw_syntax_random()) def test_parse_syntax_equality(syntax1, syntax2): equals = ( - syntax1.value == syntax2.value + syntax1.type == syntax2.type + and syntax1.value == syntax2.value and syntax1.location == syntax2.location - and syntax1.type == syntax2.type ) assert (syntax1 == syntax2) == equals