From 132a9d2c23a94ce44492e0c7800d7e06fc07f5f9 Mon Sep 17 00:00:00 2001 From: Mike Appleby <86076+appleby@users.noreply.github.com> Date: Tue, 28 May 2019 14:33:30 -0500 Subject: [PATCH] Rename test-print-instruction to test-instruction-fmt Rename the test and replace all (with-output-to-string (s) (cl-quil::print-instruction ... s)) with (format nil "~/cl-quil:instruction-fmt/" ...). Updates #116 --- tests/printer-tests.lisp | 51 +++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/tests/printer-tests.lisp b/tests/printer-tests.lisp index 710b87c3a..053ba3575 100644 --- a/tests/printer-tests.lisp +++ b/tests/printer-tests.lisp @@ -50,41 +50,32 @@ admonition against carelessness." (is (string= expected-output (parse-and-print-quil-to-string expected-output))))))))) -(deftest test-print-instruction () - (is (string= "PRAGMA gate_time CNOT \"50 ns\"" - (with-output-to-string (s) - (cl-quil::print-instruction (make-instance 'quil::pragma - :words '("gate_time" "CNOT") - :freeform-string "50 ns") - s)))) +(deftest test-instruction-fmt () + (is (string= "PRAGMA gate_time CNOT \"50 ns\"" (format nil "~/cl-quil:instruction-fmt/" + (make-instance 'quil::pragma + :words '("gate_time" "CNOT") + :freeform-string "50 ns")))) ;; try a operand-free instruction - (is (string= "HALT" - (with-output-to-string (s) - (cl-quil::print-instruction (make-instance 'halt) - s)))) + (is (string= "HALT" (format nil "~/cl-quil:instruction-fmt/" (make-instance 'halt)))) + ;; try a unary instruction - (is (string= "NEG ro[3]" - (with-output-to-string (s) - (cl-quil::print-instruction (make-instance 'quil::classical-negate - :target (mref "ro" 3)) - s)))) + (is (string= "NEG ro[3]" (format nil "~/cl-quil:instruction-fmt/" + (make-instance 'quil::classical-negate + :target (mref "ro" 3))))) ;; try a binary instruction - (is (string= "MEASURE 1 ro[3]" - (with-output-to-string (s) - (cl-quil::print-instruction (make-instance 'quil::measure - :address (mref "ro" 3) - :qubit (qubit 1)) - s)))) + (is (string= "MEASURE 1 ro[3]" (format nil "~/cl-quil:instruction-fmt/" + (make-instance 'quil::measure + :address (mref "ro" 3) + :qubit (qubit 1))))) ;; try something fancy (is (string= "CPHASE-AND-MEASURE(%alpha) 1 3 ro[5]" - (with-output-to-string (s) - (cl-quil::print-instruction (make-instance 'cl-quil::circuit-application - :operator #.(named-operator "CPHASE-AND-MEASURE") - :parameters `(,(param "alpha")) - :arguments `(,(qubit 1) - ,(qubit 3) - ,(mref "ro" 5))) - s))))) + (format nil "~/cl-quil:instruction-fmt/" + (make-instance 'cl-quil::circuit-application + :operator #.(named-operator "CPHASE-AND-MEASURE") + :parameters `(,(param "alpha")) + :arguments `(,(qubit 1) + ,(qubit 3) + ,(mref "ro" 5))))))) (deftest test-defgate-printing () (let ((befores (list "DEFGATE R(%theta, %beta):