Draft: first steps to ensure agreement - #96
Conversation
…etric operators, like equal (==) - as it is relevant for pattern matching
|
@jincge Please review. |
| """ | ||
| Assert the expected (in)equivalence of a pair of nodes (AstProtocol). | ||
| """ | ||
| match (isinstance(a, Sequence), isinstance(b, Sequence)): |
There was a problem hiding this comment.
use '_eq' so that this can be used to compare between node in production also
and in test you can just do a== b or assert_that(a, equal_to(b)) directly
There was a problem hiding this comment.
This is not an assertion, it is structural pattern matching!
There was a problem hiding this comment.
Note that the code is in test/utils/ directory so is not intended for usage by production code.
| @pytest.mark.parametrize( | ||
| "a, b, expected", make_parametersets_of_equivalence_classes("trivia", PATTERN_FACTORY.create_statements, TRIVIA_CLASSES) | ||
| ) | ||
| def test_pairs_of_equivalence_classes(self, a: AstProtocol, b: AstProtocol, expected: bool): |
There was a problem hiding this comment.
Typehints are wrong - multiple statements are a Sequence of AstNode(s) not an AstNode.
There was a problem hiding this comment.
Why didn't pylint complain?
Check type hints of create_statements - it should be a sequence.
First few restructurings to get agreement of the envisioned end goal