Skip to content

Commit 9a86a47

Browse files
committed
wrote some tests for the boolean simulation feature
1 parent 51d11e1 commit 9a86a47

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
\********************************************************************************
3+
* Copyright (c) 2023 the Qrisp authors
4+
*
5+
* This program and the accompanying materials are made available under the
6+
* terms of the Eclipse Public License 2.0 which is available at
7+
* http://www.eclipse.org/legal/epl-2.0.
8+
*
9+
* This Source Code may also be made available under the following Secondary
10+
* Licenses when the conditions for such availability set forth in the Eclipse
11+
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2
12+
* with the GNU Classpath Exception which is
13+
* available at https://www.gnu.org/software/classpath/license.html.
14+
*
15+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16+
********************************************************************************/
17+
"""
18+
19+
from qrisp import QuantumFloat, measure
20+
from qrisp.jasp import boolean_simulation, jrange
21+
22+
def test_boolean_simulation():
23+
24+
@boolean_simulation
25+
def main(i, j):
26+
27+
a = QuantumFloat(10)
28+
29+
b = QuantumFloat(10)
30+
31+
a[:] = i
32+
b[:] = j
33+
34+
c = QuantumFloat(30)
35+
36+
for i in jrange(150):
37+
c += a*b
38+
39+
return measure(c)
40+
41+
for i in range(5):
42+
for j in range(5):
43+
assert main(i, j) == 150*i*j

0 commit comments

Comments
 (0)