Skip to content

Commit

Permalink
Add testcase for #10
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialeezero committed Nov 25, 2024
1 parent 0872367 commit daeec32
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ALL_AEXPS,
ALL_GATES,
CX,
Add,
Aexp,
Cmd,
ForCmd,
Expand Down Expand Up @@ -78,3 +79,17 @@ def test_hole_aexp3():
if type(pgm.body.gate.qreg2) not in [Integer, Var]:
aexp_types.remove(type(pgm.body.gate.qreg2))
assert len(aexp_types) == 3


def test_next_aexp():
pgm = Pgm("n", GateCmd(CX(Integer(0), Add())))
aexp_types: list[type[Aexp]] = ALL_AEXPS.copy()
pgms = next(pgm)
for pgm in pgms:
assert isinstance(pgm.body, GateCmd)
assert isinstance(pgm.body.gate, CX)
assert isinstance(pgm.body.gate.qreg2, Add)
assert type(pgm.body.gate.qreg2.a) in aexp_types
if type(pgm.body.gate.qreg2.a) not in [Integer, Var]:
aexp_types.remove(type(pgm.body.gate.qreg2.a))
assert len(aexp_types) == 3

0 comments on commit daeec32

Please sign in to comment.