Skip to content

Commit

Permalink
add testcase for appending two filled circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf committed Nov 22, 2024
1 parent 5d833d6 commit d9e6dac
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tket/test/src/test_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,37 @@ SCENARIO("generating circ with wasm") {
REQUIRE(u2.w_inputs().size() == 1);
REQUIRE(u2.w_outputs().size() == 1);
}
GIVEN("circuit with wasm append 4") {
Circuit u(1, 1);
Circuit u2(1, 1);

const std::shared_ptr<WASMOp> wop_ptr =
std::make_shared<WASMOp>(2, 1, uv_2, uv_2, wasm_func, wasm_file);

const std::shared_ptr<WASMOp> wop_ptr_2 =
std::make_shared<WASMOp>(1, 1, uv_2, uv_3, wasm_func, wasm_file);

const std::shared_ptr<WASMOp> wop_ptr_3 =
std::make_shared<WASMOp>(1, 3, uv_3, uv_2, wasm_func, wasm_file);

u.add_op<UnitID>(wop_ptr, {Bit(0), Bit(0), WasmState(0)});
u.add_op<UnitID>(wop_ptr_2, {Bit(0), WasmState(0)});
u2.add_op<UnitID>(
wop_ptr_3, {Bit(0), WasmState(0), WasmState(1), WasmState(2)});

u.assert_valid();
u2.assert_valid();
REQUIRE(u.depth() == 2);
REQUIRE(u.w_inputs().size() == 1);
REQUIRE(u.w_outputs().size() == 1);
REQUIRE(u2.depth() == 1);
REQUIRE(u2.w_inputs().size() == 3);
REQUIRE(u2.w_outputs().size() == 3);
u2.append(u);
REQUIRE(u2.depth() == 3);
REQUIRE(u2.w_inputs().size() == 3);
REQUIRE(u2.w_outputs().size() == 3);
}
}

SCENARIO("test wasm uid") {
Expand Down

0 comments on commit d9e6dac

Please sign in to comment.