def test_unary_classicals(): p = Program() p.inst(TRUE(0), FALSE(Addr(1)), NOT(Addr(2)), NEG(Addr(3))) assert p.out() == 'MOVE ro[0] 1\n' \ 'MOVE ro[1] 0\n' \ 'NOT ro[2]\n' \ 'NEG ro[3]\n'
def test_unary_classicals(): p = Program() p.inst( MOVE(MemoryReference("ro", 0), 1), MOVE(MemoryReference("ro", 1), 0), NOT(MemoryReference("ro", 2)), NEG(MemoryReference("ro", 3)), ) assert p.out() == "MOVE ro[0] 1\nMOVE ro[1] 0\nNOT ro[2]\nNEG ro[3]\n"
def test_unary_classicals(): p = Program() p.inst(TRUE(MemoryReference("ro", 0)), FALSE(MemoryReference("ro", 1)), NOT(MemoryReference("ro", 2)), NEG(MemoryReference("ro", 3))) assert p.out() == 'MOVE ro[0] 1\n' \ 'MOVE ro[1] 0\n' \ 'NOT ro[2]\n' \ 'NEG ro[3]\n'
def test_all_instructions(): pq = Program(H(0), X(1), RX(1.2, 2), CNOT(0, 1), CCNOT(0, 1, 2)) ro = pq.declare("ro") pq.measure(0, ro) pq.defgate("mygate", [[1, 0], [0, 1]]) pq.inst(("mygate", 0)) pq.reset(0) pq += Program(NEG(ro), AND(ro, ro), ADD(ro, 1), EQ(ro, ro, ro)) pq += Program(EXCHANGE(ro, ro), CONVERT(ro, ro)) pq += Program(LOAD(ro, ro, ro), STORE(ro, ro, ro)) G = QuilControlFlowGraph(pq) assert len(G.blocks) == 1 assert set(G.nodes) == set([0]) assert set(G.edges) == set() assert G.is_dag()