diff --git a/compiler/qsc/src/interpret/circuit_tests.rs b/compiler/qsc/src/interpret/circuit_tests.rs index 4a17be1d6c..f5d380d3b9 100644 --- a/compiler/qsc/src/interpret/circuit_tests.rs +++ b/compiler/qsc/src/interpret/circuit_tests.rs @@ -70,6 +70,33 @@ fn one_gate() { .assert_eq(&circ.to_string()); } +#[test] +fn toffoli() { + let mut interpreter = interpreter( + r" + namespace Test { + @EntryPoint() + operation Main() : Unit { + use q = Qubit[3]; + CCNOT(q[0], q[1], q[2]); + } + } + ", + Profile::Unrestricted, + ); + + let circ = interpreter + .circuit(CircuitEntryPoint::EntryPoint, false) + .expect("circuit generation should succeed"); + + expect![[r" + q_0 ── ● ── + q_1 ── ● ── + q_2 ── X ── + "]] + .assert_eq(&circ.to_string()); +} + #[test] fn rotation_gate() { let mut interpreter = interpreter( diff --git a/compiler/qsc_circuit/src/builder.rs b/compiler/qsc_circuit/src/builder.rs index b34b2796e9..c40d8d9be6 100644 --- a/compiler/qsc_circuit/src/builder.rs +++ b/compiler/qsc_circuit/src/builder.rs @@ -26,7 +26,7 @@ impl Backend for Builder { let ctl0 = self.map(ctl0); let ctl1 = self.map(ctl1); let q = self.map(q); - self.push_gate(controlled_gate("CX", [ctl0, ctl1], [q])); + self.push_gate(controlled_gate("X", [ctl0, ctl1], [q])); } fn cx(&mut self, ctl: usize, q: usize) {