-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add list, loop, and comprehension tests #71
Conversation
guppy/module.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are drive-by fixes to get function declaration inside classes to work
|
||
11: @guppy(module) | ||
12: def foo(qs: linst[tuple[Qubit, Qubit]]) -> linst[Qubit]: | ||
13: return [q for q, q in qs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be worth giving the bindings different names to make the error case more obvious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same name on purpose to test that the error is still triggered. The regular unused case is already tested in tests/error/comprehension_errors/not_used.py
"""A type where the `__iter__` method has the wrong signature.""" | ||
|
||
@guppy.declare(module) | ||
def __iter__(self: "MyType", x: int) -> "MyType": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this work if MyType defined the iterator methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if MyType defines __iter__
as identity
tests/integration/test_for.py
Outdated
validate(foo) | ||
|
||
validate(foo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double validate?
|
||
@guppy(module) | ||
def test(xs: linst[Qubit]) -> tuple[int, linst[Qubit]]: | ||
return len(xs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having len
return a different type to expected could confuse people, have we considered renaming it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created issue #103
Some tests are failing since the fix from CQCL/hugr#749 is not yet merged in