19
19
20
20
from qlasskit import QlassF , exceptions , qlassf # Qint2
21
21
22
- from .utils import COMPILATION_ENABLED , compare_circuit_truth_table
22
+ from .utils import COMPILATION_ENABLED , compute_and_compare_results
23
23
24
24
a , b , c , d = symbols ("a,b,c,d" )
25
25
_ret = Symbol ("_ret" )
@@ -43,7 +43,7 @@ def test_int_arg2(self):
43
43
qf .expressions [0 ][1 ],
44
44
ITE (And (Symbol ("a.0" ), b ), Symbol ("a.1" ), Symbol ("a.0" )),
45
45
)
46
- compare_circuit_truth_table (self , qf )
46
+ compute_and_compare_results (self , qf )
47
47
48
48
def test_const_return (self ):
49
49
f = "def test(a: Qint2) -> Qint2:\n \t return 1"
@@ -61,15 +61,15 @@ def test_int_return_tuple(self):
61
61
f = "def test(a: Qint2) -> Tuple[Qint2, bool]:\n \t b = a[0] and a[1]\n \t return (a, b)"
62
62
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
63
63
self .assertEqual (len (qf .expressions ), 4 )
64
- compare_circuit_truth_table (self , qf )
64
+ compute_and_compare_results (self , qf )
65
65
66
66
def test_int_tuple (self ):
67
67
f = "def test(a: Tuple[Qint2, Qint2]) -> bool:\n \t return a[0][0] and a[1][1]"
68
68
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
69
69
self .assertEqual (len (qf .expressions ), 1 )
70
70
self .assertEqual (qf .expressions [0 ][0 ], _ret )
71
71
self .assertEqual (qf .expressions [0 ][1 ], And (Symbol ("a.0.0" ), Symbol ("a.1.1" )))
72
- compare_circuit_truth_table (self , qf )
72
+ compute_and_compare_results (self , qf )
73
73
74
74
def test_int_identity (self ):
75
75
f = "def test(a: Qint2) -> Qint2:\n \t return a"
@@ -79,7 +79,7 @@ def test_int_identity(self):
79
79
self .assertEqual (qf .expressions [0 ][1 ], Symbol ("a.0" ))
80
80
self .assertEqual (qf .expressions [1 ][0 ], Symbol ("_ret.1" ))
81
81
self .assertEqual (qf .expressions [1 ][1 ], Symbol ("a.1" ))
82
- compare_circuit_truth_table (self , qf )
82
+ compute_and_compare_results (self , qf )
83
83
84
84
# TODO: need consts
85
85
# def test_int_const(self):
@@ -92,7 +92,7 @@ def test_int_const_compare_eq(self):
92
92
self .assertEqual (len (qf .expressions ), 1 )
93
93
self .assertEqual (qf .expressions [0 ][0 ], _ret )
94
94
self .assertEqual (qf .expressions [0 ][1 ], And (Symbol ("a.1" ), Not (Symbol ("a.0" ))))
95
- compare_circuit_truth_table (self , qf )
95
+ compute_and_compare_results (self , qf )
96
96
97
97
def test_int_const_compare_eq_different_type (self ):
98
98
f = "def test(a: Qint4) -> bool:\n \t return a == 2"
@@ -108,7 +108,7 @@ def test_int_const_compare_eq_different_type(self):
108
108
Not (Symbol ("a.3" )),
109
109
),
110
110
)
111
- compare_circuit_truth_table (self , qf )
111
+ compute_and_compare_results (self , qf )
112
112
113
113
def test_const_int_compare_eq_different_type (self ):
114
114
f = "def test(a: Qint4) -> bool:\n \t return 2 == a"
@@ -124,7 +124,7 @@ def test_const_int_compare_eq_different_type(self):
124
124
Not (Symbol ("a.3" )),
125
125
),
126
126
)
127
- compare_circuit_truth_table (self , qf )
127
+ compute_and_compare_results (self , qf )
128
128
129
129
def test_const_int_compare_neq_different_type (self ):
130
130
f = "def test(a: Qint4) -> bool:\n \t return 2 != a"
@@ -140,7 +140,7 @@ def test_const_int_compare_neq_different_type(self):
140
140
Symbol ("a.3" ),
141
141
),
142
142
)
143
- compare_circuit_truth_table (self , qf )
143
+ compute_and_compare_results (self , qf )
144
144
145
145
def test_int_int_compare_eq (self ):
146
146
f = "def test(a: Qint2, b: Qint2) -> bool:\n \t return a == b"
@@ -154,7 +154,7 @@ def test_int_int_compare_eq(self):
154
154
Not (Xor (Symbol ("a.1" ), Symbol ("b.1" ))),
155
155
),
156
156
)
157
- compare_circuit_truth_table (self , qf )
157
+ compute_and_compare_results (self , qf )
158
158
159
159
def test_int_int_compare_neq (self ):
160
160
f = "def test(a: Qint2, b: Qint2) -> bool:\n \t return a != b"
@@ -168,21 +168,21 @@ def test_int_int_compare_neq(self):
168
168
Xor (Symbol ("a.1" ), Symbol ("b.1" )),
169
169
),
170
170
)
171
- compare_circuit_truth_table (self , qf )
171
+ compute_and_compare_results (self , qf )
172
172
173
173
def test_const_int_compare_gt (self ):
174
174
f = "def test(a: Qint2) -> bool:\n \t return a > 1"
175
175
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
176
176
self .assertEqual (len (qf .expressions ), 1 )
177
177
self .assertEqual (qf .expressions [0 ][0 ], _ret )
178
- compare_circuit_truth_table (self , qf )
178
+ compute_and_compare_results (self , qf )
179
179
180
180
def test_const_int4_compare_gt (self ):
181
181
f = "def test(a: Qint4) -> bool:\n \t return a > 6"
182
182
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
183
183
self .assertEqual (len (qf .expressions ), 1 )
184
184
self .assertEqual (qf .expressions [0 ][0 ], _ret )
185
- compare_circuit_truth_table (self , qf )
185
+ compute_and_compare_results (self , qf )
186
186
187
187
# def test_int4_int4_compare_gt(self):
188
188
# f = "def test(a: Qint4, b: Qint4) -> bool:\n\treturn a > b"
@@ -196,28 +196,28 @@ def test_const_int_compare_lt(self):
196
196
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
197
197
self .assertEqual (len (qf .expressions ), 1 )
198
198
self .assertEqual (qf .expressions [0 ][0 ], _ret )
199
- compare_circuit_truth_table (self , qf )
199
+ compute_and_compare_results (self , qf )
200
200
201
201
def test_const_int4_compare_lt (self ):
202
202
f = "def test(a: Qint4) -> bool:\n \t return a < 6"
203
203
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
204
204
self .assertEqual (len (qf .expressions ), 1 )
205
205
self .assertEqual (qf .expressions [0 ][0 ], _ret )
206
- compare_circuit_truth_table (self , qf )
206
+ compute_and_compare_results (self , qf )
207
207
208
208
def test_int_int_compare_gt (self ):
209
209
f = "def test(a: Qint2, b: Qint2) -> bool:\n \t return a > b"
210
210
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
211
211
self .assertEqual (len (qf .expressions ), 1 )
212
212
self .assertEqual (qf .expressions [0 ][0 ], _ret )
213
- compare_circuit_truth_table (self , qf )
213
+ compute_and_compare_results (self , qf )
214
214
215
215
def test_int_int_compare_lt (self ):
216
216
f = "def test(a: Qint2, b: Qint2) -> bool:\n \t return a < b"
217
217
qf = qlassf (f , to_compile = COMPILATION_ENABLED )
218
218
self .assertEqual (len (qf .expressions ), 1 )
219
219
self .assertEqual (qf .expressions [0 ][0 ], _ret )
220
- compare_circuit_truth_table (self , qf )
220
+ compute_and_compare_results (self , qf )
221
221
222
222
# def test_const_int_compare_gte(self):
223
223
# f = "def test(a: Qint2, b: Qint2) -> bool:\n\treturn a >= b"
0 commit comments