Skip to content

Commit

Permalink
feat: Add equality test for booleans (#394)
Browse files Browse the repository at this point in the history
Closes #363
  • Loading branch information
croyzor authored Aug 21, 2024
1 parent 0fdbbbb commit dd702ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions guppylang/prelude/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def __and__(self: bool, other: bool) -> bool: ...
@guppy.custom(builtins, NoopCompiler())
def __bool__(self: bool) -> bool: ...

@guppy.hugr_op(builtins, logic_op("Eq", [tys.TypeArg(tys.BoundedNatArg(n=2))]))
def __eq__(self: bool, other: bool) -> bool: ...

@guppy.hugr_op(builtins, int_op("ifrombool"))
def __int__(self: bool) -> int: ...

Expand Down
10 changes: 10 additions & 0 deletions tests/integration/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,13 @@ def foo(x: int) -> int:
return z

validate(foo)


def test_eq(validate):
@compile_guppy
def foo() -> bool:
x = True
y = not x
return x == y

validate(foo)

0 comments on commit dd702ce

Please sign in to comment.