-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #270
- Loading branch information
Showing
9 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Guppy compilation failed. Error in file $FILE:7 | ||
|
||
5: @compile_guppy | ||
6: def foo(x: int) -> None: | ||
7: result((), x) | ||
^^ | ||
GuppyTypeError: Expected an int literal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from guppylang.prelude.builtins import result | ||
from tests.util import compile_guppy | ||
|
||
|
||
@compile_guppy | ||
def foo(x: int) -> None: | ||
result((), x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Guppy compilation failed. Error in file $FILE:7 | ||
|
||
5: @compile_guppy | ||
6: def foo(x: int, y: bool) -> None: | ||
7: result(x, y) | ||
^ | ||
GuppyTypeError: Expected an int literal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from guppylang.prelude.builtins import result | ||
from tests.util import compile_guppy | ||
|
||
|
||
@compile_guppy | ||
def foo(x: int, y: bool) -> None: | ||
result(x, y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Guppy compilation failed. Error in file $FILE:14 | ||
|
||
12: @guppy(module) | ||
13: def foo(q: qubit) -> None: | ||
14: result(0, q) | ||
^ | ||
GuppyTypeError: Cannot use value with linear type `qubit` as a result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import guppylang.prelude.quantum as quantum | ||
from guppylang.decorator import guppy | ||
from guppylang.module import GuppyModule | ||
from guppylang.prelude.builtins import result | ||
from guppylang.prelude.quantum import qubit | ||
|
||
|
||
module = GuppyModule("test") | ||
module.load(quantum) | ||
|
||
|
||
@guppy(module) | ||
def foo(q: qubit) -> None: | ||
result(0, q) | ||
|
||
|
||
module.compile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from hugr.serialization import ops | ||
|
||
from guppylang.decorator import guppy | ||
from guppylang.module import GuppyModule | ||
from guppylang.prelude.builtins import result | ||
from tests.util import compile_guppy | ||
|
||
|
||
def test_single(validate): | ||
@compile_guppy | ||
def main(x: int) -> None: | ||
result(0, x) | ||
|
||
validate(main) | ||
|
||
|
||
def test_value(validate): | ||
@compile_guppy | ||
def main(x: int) -> None: | ||
return result(0, x) | ||
|
||
validate(main) | ||
|
||
|
||
def test_nested(validate): | ||
@compile_guppy | ||
def main(x: int, y: float, z: bool) -> None: | ||
result(42, (x, (y, z))) | ||
|
||
validate(main) | ||
|
||
|
||
def test_multi(validate): | ||
@compile_guppy | ||
def main(x: int, y: float, z: bool) -> None: | ||
result(0, x) | ||
result(1, y) | ||
result(2, z) | ||
|
||
validate(main) | ||
|
||
|
||
def test_same_tag(validate): | ||
@compile_guppy | ||
def main(x: int, y: float, z: bool) -> None: | ||
result(0, x) | ||
result(0, y) | ||
result(0, z) | ||
|
||
validate(main) |