Skip to content

Commit

Permalink
Add descriptive names for DEFGATE/DEFCIRCUIT golden tests
Browse files Browse the repository at this point in the history
This aids debuggability in case of failing tests.
  • Loading branch information
appleby committed Jun 3, 2019
1 parent e6b7734 commit 8bd1273
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 41 deletions.
16 changes: 8 additions & 8 deletions tests/printer-test-files/defgates.quil
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
# representation will be a "DEFGATE R as PERMUTATION" not a "DEFGATE R", hence we disable the
# fixed-point check for this input.

DEFGATE R:
DEFGATE TEST-NOT-FIXED-POINT:
exp(i*0), 0
0, exp(0/i)

R 0
TEST-NOT-FIXED-POINT 0

# Output
DEFGATE R:
DEFGATE TEST-NOT-FIXED-POINT:
1.0, 0.0
0.0, 1.0


R 0
TEST-NOT-FIXED-POINT 0

# Input

# If we modify the DEFGATE from the previous Input section slightly so that it's no longer a
# permutation matrix, then the output passes the fixed-point check.

DEFGATE R:
DEFGATE TEST-FIXED-POINT:
exp(i*0), 0
1, exp(0/i)

R 0
TEST-FIXED-POINT 0

# Output
DEFGATE R:
DEFGATE TEST-FIXED-POINT:
1.0, 0.0
1.0, 1.0


R 0
TEST-FIXED-POINT 0

46 changes: 23 additions & 23 deletions tests/printer-test-files/delayed-expressions.quil
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# Input
DEFGATE TEST(%arg):
DEFGATE TEST-BINARY-ARITH(%arg):
%arg+%arg, %arg-%arg
%arg/%arg, %arg^%arg

# Output
DEFGATE TEST(%arg):
DEFGATE TEST-BINARY-ARITH(%arg):
(%arg+%arg), (%arg-%arg)
(%arg/%arg), (%arg^%arg)



# Input
DEFGATE TEST(%arg):
DEFGATE TEST-ARITH-ASSOC(%arg):
2*%arg+%arg/pi, %arg^2-%arg+2*%arg
%arg*2/2*%arg, %arg^%arg^%arg

# Output
DEFGATE TEST(%arg):
DEFGATE TEST-ARITH-ASSOC(%arg):
(((2.0)*%arg)+(%arg/(pi))), (((%arg^(2.0))-%arg)+((2.0)*%arg))
(((%arg*(2.0))/(2.0))*%arg), (%arg^(%arg^%arg))



# Input
DEFGATE TEST(%arg):
DEFGATE TEST-FUNCTIONS(%arg):
COS(%arg), SIN(%arg), CIS(%arg), SQRT(%arg)
EXP(%arg), SIN(pi/%arg), COS(pi/2*%arg), CIS(%arg*i),
SIN(2*%arg), EXP(1+%arg), SQRT(%arg^2), SQRT(%arg)^2
COS(SIN(%arg)), SIN(%arg)^2+COS(%arg)^2, SIN(%arg)/SIN(%arg), SIN(%arg)/COS(%arg)

# Output
DEFGATE TEST(%arg):
DEFGATE TEST-FUNCTIONS(%arg):
COS(%arg), SIN(%arg), CIS(%arg), SQRT(%arg)
EXP(%arg), SIN(((pi)/%arg)), COS((((pi)/(2.0))*%arg)), CIS((%arg*(1.0i)))
SIN(((2.0)*%arg)), EXP(((1.0)+%arg)), SQRT((%arg^(2.0))), (SQRT(%arg)^(2.0))
Expand All @@ -39,76 +39,76 @@ DEFGATE TEST(%arg):


# Input
DEFGATE TEST(%arg):
DEFGATE TEST-EXPT-ASSOC(%arg):
%arg*COS(%arg/2+2^2)^2^4, 0
0, 0

# Output
DEFGATE TEST(%arg):
DEFGATE TEST-EXPT-ASSOC(%arg):
(%arg*(COS(((%arg/(2.0))+((2.0)^(2.0))))^((2.0)^(4.0)))), 0.0
0.0, 0.0



# Input
DEFGATE TEST(%arg1, %arg2, %arg3):
DEFGATE TEST-INFIX-ASSOC(%arg1, %arg2, %arg3):
(%arg1*%arg2+(%arg3/pi)^2)/pi, 0
0, 0

# Output
DEFGATE TEST(%arg1, %arg2, %arg3):
DEFGATE TEST-INFIX-ASSOC(%arg1, %arg2, %arg3):
(((%arg1*%arg2)+((%arg3/(pi))^(2.0)))/(pi)), 0.0
0.0, 0.0



# Input
DEFGATE TEST(%arg1, %arg2):
DEFGATE TEST-EXPT(%arg1, %arg2):
0, 0
0, %arg1^%arg2

# Output
DEFGATE TEST(%arg1, %arg2):
DEFGATE TEST-EXPT(%arg1, %arg2):
0.0, 0.0
0.0, (%arg1^%arg2)



# Input
DEFGATE UNARY-MINUS(%arg1):
DEFGATE TEST-UNARY-MINUS(%arg1):
0, -1
0, -%arg1

# Output
DEFGATE UNARY-MINUS(%arg1):
DEFGATE TEST-UNARY-MINUS(%arg1):
0.0, -1.0
0.0, -(%arg1)



# Input
DEFGATE R(%theta, %beta):
DEFGATE TEST-R(%theta, %beta):
exp(%beta/3*i), 0
0, exp(%theta/2*i)

R(pi/2, pi/8) 0
TEST-R(pi/2, pi/8) 0

# Output
DEFGATE R(%theta, %beta):
DEFGATE TEST-R(%theta, %beta):
EXP(((%beta/(3.0))*(1.0i))), 0.0
0.0, EXP(((%theta/(2.0))*(1.0i)))


R(pi/2, pi/8) 0
TEST-R(pi/2, pi/8) 0

# Input
DEFCIRCUIT TEST(%arg1, %arg2) p:
DEFCIRCUIT TEST-CIRCUIT-EXPANSION(%arg1, %arg2) p:
RX(%arg1-%arg2) p

TEST(pi, pi*SIN(pi/2)) 0
TEST-CIRCUIT-EXPANSION(pi, pi*SIN(pi/2)) 0

# Output
DEFCIRCUIT TEST(%arg1, %arg2) p:
DEFCIRCUIT TEST-CIRCUIT-EXPANSION(%arg1, %arg2) p:
RX((%arg1-%arg2)) p


Expand All @@ -117,14 +117,14 @@ RX(0.0) 0
# Input
DECLARE int INTEGER[2]

DEFGATE MREF(%arg):
DEFGATE TEST-MREF(%arg):
%arg*int, int[1]/%arg
int[0]^%arg, COS(int+%arg)

# Output
DECLARE int INTEGER[2]

DEFGATE MREF(%arg):
DEFGATE TEST-MREF(%arg):
(%arg*int[0]), (int[1]/%arg)
(int[0]^%arg), COS((int[0]+%arg))

Expand Down
8 changes: 4 additions & 4 deletions tests/printer-test-files/gh-issue-249.quil
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Input
DEFGATE TEST(%arg):
DEFGATE TEST-GH-ISSUE-249(%arg):
COS(%arg)^2, 0
0, SIN(%arg)^2

TEST(0.5) 0
TEST-GH-ISSUE-249(0.5) 0
# Output
DEFGATE TEST(%arg):
DEFGATE TEST-GH-ISSUE-249(%arg):
(COS(%arg)^(2.0)), 0.0
0.0, (SIN(%arg)^(2.0))


TEST(0.5) 0
TEST-GH-ISSUE-249(0.5) 0

12 changes: 6 additions & 6 deletions tests/printer-test-files/permutation-gates.quil
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Input
DEFGATE TEST:
DEFGATE TEST-PERM-01:
pi/pi, 0
0, 2^4/16
# Output
DEFGATE TEST AS PERMUTATION:
DEFGATE TEST-PERM-01 AS PERMUTATION:
0, 1


# Input
DEFGATE TEST:
DEFGATE TEST-PERM-10:
0, 1
1, 0
# Output
DEFGATE TEST AS PERMUTATION:
DEFGATE TEST-PERM-10 AS PERMUTATION:
1, 0


# Input
DEFGATE PERM AS PERMUTATION:
DEFGATE PERM-AS-PERM AS PERMUTATION:
1, 0, 3, 2

# Output
DEFGATE PERM AS PERMUTATION:
DEFGATE PERM-AS-PERM AS PERMUTATION:
1, 0, 3, 2


0 comments on commit 8bd1273

Please sign in to comment.