Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Apr 17, 2024
1 parent 8415749 commit c6f317d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/source/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ method.

# Declare our memory spaces
branching_prog = Program()
test_register = branching_prog.declare('test_register', 'BIT')
ro = branching_prog.declare('ro', 'BIT')
test_register = branching_prog.declare('test_register', 'BIT')

# Construct each branch of our if-statement. We can have empty branches
# simply by having empty programs.
Expand Down
15 changes: 12 additions & 3 deletions test/unit/__snapshots__/test_quil.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@

'''
# ---
# name: test_classical_regs
'''
DECLARE reg BIT[2]
DECLARE ro BIT[2]
X 0
MEASURE 0 reg[1]

'''
# ---
# name: test_construction_syntax
'''
DECLARE ro BIT[2]
Expand Down Expand Up @@ -338,13 +347,13 @@
# ---
# name: test_prog_merge.1
'''
DEFGATE PERM AS PERMUTATION:
0, 1, 3, 2

DEFGATE test AS MATRIX:
1, 0
0, 1

DEFGATE PERM AS PERMUTATION:
0, 1, 3, 2

X 0
test 0
PERM 0 1
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_quil.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ def test_prog_init(snapshot):
assert p.out() == snapshot


def test_classical_regs():
def test_classical_regs(snapshot: SnapshotAssertion):
p = Program()
p.inst(
Declare("ro", "BIT", 2),
Declare("reg", "BIT", 2),
Declare("ro", "BIT", 2),
X(0),
).measure(0, MemoryReference("reg", 1))
assert p.out() == "DECLARE reg BIT[2]\nDECLARE ro BIT[2]\nX 0\nMEASURE 0 reg[1]\n"
assert p.out() == snapshot
assert p.declarations == {
"reg": Declare("reg", "BIT", 2),
"ro": Declare("ro", "BIT", 2),
Expand Down
5 changes: 2 additions & 3 deletions test/unit/test_rewrite_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ def test_rewrite_arithmetic_mixed():
ParameterAref(index=1, name="__P2"): "(beta[0] + theta[0])/(2*pi)",
}
assert (
response.quil
== Program(
Program(response.quil) == Program(
"DECLARE __P2 REAL[2]",
"DECLARE theta REAL[1]",
"DECLARE beta REAL[1]",
"RZ(__P2[0]) 0",
"RZ(__P2[1]) 0",
).out()
)
)


Expand Down

0 comments on commit c6f317d

Please sign in to comment.