Skip to content
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

Merged
merged 35 commits into from
Jan 16, 2024
Merged

Conversation

mark-koch
Copy link
Collaborator

@mark-koch mark-koch commented Dec 20, 2023

Some tests are failing since the fix from CQCL/hugr#749 is not yet merged in

guppy/module.py Outdated
Copy link
Collaborator Author

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

@ss2165 ss2165 added this to the Release v0.1 milestone Jan 10, 2024

11: @guppy(module)
12: def foo(qs: linst[tuple[Qubit, Qubit]]) -> linst[Qubit]:
13: return [q for q, q in qs]
Copy link
Member

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

Copy link
Collaborator Author

@mark-koch mark-koch Jan 15, 2024

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":
Copy link
Member

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?

Copy link
Collaborator Author

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

Comment on lines 82 to 84
validate(foo)

validate(foo)
Copy link
Member

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)
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue #103

@mark-koch mark-koch self-assigned this Jan 16, 2024
Base automatically changed from lists/compile to feat/lists January 16, 2024 13:10
@mark-koch mark-koch merged commit 449ca6f into feat/lists Jan 16, 2024
1 check passed
@mark-koch mark-koch deleted the lists/test branch January 16, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants