Skip to content

Commit

Permalink
marco and block test
Browse files Browse the repository at this point in the history
  • Loading branch information
liam committed Sep 18, 2023
1 parent b7f8f53 commit 0a0650f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/YaoBlocksQASM.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module YaoBlocksQASM

export convert_to_qasm, @qasm_str
export convert_to_qasm, toblocks, @qasm_str

using YaoBlocks

Expand Down
46 changes: 16 additions & 30 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ using Test
Yao.Measure(3),
)

qc_blocks = toblocks(Module(), LineNumberNode(1), OpenQASM.parse( qasm))

@testset "convert YaoBlocks to QASM" begin
ast1 = convert_to_qasm(qc, 1)

Expand All @@ -57,7 +59,13 @@ using Test
end

@testset "convert QASM to YaoBlocks" begin
circuit1 = qasm"""OPENQASM 2.0;
@info typeof(qc_blocks)
println("converted circuit $qc_blocks")

end

@testset "use marco" begin
circuit = @qasm_str """OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c1[3];
Expand All @@ -79,36 +87,14 @@ using Test
measure q[1] -> c1[1];
measure q[2] -> c1[2];
"""
circuit2 = @qasm_str """OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c1[3];
h q[0];
CX q[1],q[2];
cy q[1],q[0];
cz q[0],q[2];
x q[0];
swap q[1],q[2];
id q[0];
t q[1];
rz(0.7) q[2];
z q[0];
p(0.7) q[1];
ry(0.7) q[2];
y q[0];
rx(0.7) q[1];
measure q[0] -> c1[0];
measure q[1] -> c1[1];
measure q[2] -> c1[2];
"""
@info circuit
@info typeof(circuit)
dump(circuit)
print("converted circuit $circuit")

@test qc == circuit
# TODO implemet full test
println(circuit)
end

# @testset "check equivalence of converting to and from OpenQASM from YaoBlocks" begin
# reconverted_circuit = convert_to_qasm(qc,3)
# @test circuit == reconverted_circuit
# # TODO implemet full test
# end


end

0 comments on commit 0a0650f

Please sign in to comment.