Commit f12da69a authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Added a test to verify the multiple-call test case



To verify this on the CI build to debug the root cause.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 12b1d060
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ add_qcor_compile_and_exe_test(qrt_qpu_lambdas_in_loop qpu_lambda/deuteron_lambda
add_qcor_compile_and_exe_test(qrt_qpu_lambda_deuteron qpu_lambda/deuteron_vqe.cpp)
add_qcor_compile_and_exe_test(qrt_qpu_lambda_objfunc qpu_lambda/deuteron_vqe_obj_func.cpp)
add_qcor_compile_and_exe_test(qrt_qpu_lambda_hadamard_test ctrl-gates/hadamard_test.cpp)
add_qcor_compile_and_exe_test(qrt_qpu_lambda_multiple_calls qpu_lambda/lambda_multiple_bell.cpp)

# Arithmetic tests
add_qcor_compile_and_exe_test(qrt_qpu_arith_adder arithmetic/simple.cpp)
+30 −0
Original line number Diff line number Diff line
#include "qcor.hpp"

void test_run() {
  auto x_lambda = qpu_lambda([](qubit q) { X(q); });

  auto bell = qpu_lambda(
      [](qreg q) {
        H(q[0]);
        // Call the captured lambda
        x_lambda.ctrl(q[0], q[1]);
        Measure(q);
      },
      x_lambda);

  auto q = qalloc(2);
  bell(q);
  q.print();
  qcor_expect(q.counts().size() == 2);
  qcor_expect(q.counts()["00"] > 400);
  qcor_expect(q.counts()["11"] > 400);
  // Entangled...
  qcor_expect(q.counts()["00"] + q.counts()["11"] == 1024);
}

int main(int argc, char **argv) {
  set_shots(1024);
  // Call a function containing qpu_lambda multiple times.
  test_run();
  test_run();
}