diff --git a/pytket/tests/classical_test.py b/pytket/tests/classical_test.py index ceeda6b421..49a9203fb2 100644 --- a/pytket/tests/classical_test.py +++ b/pytket/tests/classical_test.py @@ -192,6 +192,18 @@ def test_wasm_3() -> None: assert c.depth() == 1 +def test_wasm_3_bytes() -> None: + with open("testfile.wasm", "rb") as f: + bytecode = f.read() + c = Circuit(0, 6) + + w = wasm.WasmModuleHandler(bytecode) + + c.add_wasm("add_one", w, [1], [1], [Bit(0), Bit(1)]) + + assert c.depth() == 1 + + def test_wasm_4() -> None: w = wasm.WasmFileHandler("testfile.wasm") @@ -412,6 +424,19 @@ def test_wasm_function_check_6() -> None: assert c.depth() == 1 +def test_wasm_function_check_6_bytes() -> None: + with open("testfile.wasm", "rb") as f: + bytecode = f.read() + + w = wasm.WasmModuleHandler(bytecode) + c = Circuit(20, 20) + c0 = c.add_c_register("c0", 32) + c1 = c.add_c_register("c1", 4) + + c.add_wasm_to_reg("add_one", w, [c0], [c1]) + assert c.depth() == 1 + + def test_wasm_function_check_7() -> None: w = wasm.WasmFileHandler("testfile.wasm", int_size=32) c = Circuit(20, 20) @@ -566,7 +591,7 @@ def test_wasmfilehandler_repr() -> None: function 'no_return' with 1 i32 parameter(s) and 0 i32 return value(s) function 'no_parameters' with 0 i32 parameter(s) and 1 i32 return value(s) function 'new_function' with 0 i32 parameter(s) and 1 i32 return value(s) -unsupported function with invalid parameter or result type: 'add_something' +unsupported function with invalid parameter or result type: 'add_something' """ ) @@ -578,13 +603,13 @@ def test_wasmfilehandler_repr_64() -> None: == """Functions in wasm file with the uid 6a0a29e235cd5c60353254bc2b459e631d381cdd0bded7ae6cb44afb784bd2de: function 'init' with 0 i64 parameter(s) and 0 i64 return value(s) function 'add_something' with 1 i64 parameter(s) and 1 i64 return value(s) -unsupported function with invalid parameter or result type: 'add_one' -unsupported function with invalid parameter or result type: 'multi' -unsupported function with invalid parameter or result type: 'add_two' -unsupported function with invalid parameter or result type: 'add_eleven' -unsupported function with invalid parameter or result type: 'no_return' -unsupported function with invalid parameter or result type: 'no_parameters' -unsupported function with invalid parameter or result type: 'new_function' +unsupported function with invalid parameter or result type: 'add_one' +unsupported function with invalid parameter or result type: 'multi' +unsupported function with invalid parameter or result type: 'add_two' +unsupported function with invalid parameter or result type: 'add_eleven' +unsupported function with invalid parameter or result type: 'no_return' +unsupported function with invalid parameter or result type: 'no_parameters' +unsupported function with invalid parameter or result type: 'new_function' """ ) @@ -607,7 +632,7 @@ def test_wasmfilehandler_repr_2() -> None: function 'mixed_up_2' with 2 i32 parameter(s) and 1 i32 return value(s) function 'mixed_up_3' with 3 i32 parameter(s) and 1 i32 return value(s) function 'unse_internal' with 1 i32 parameter(s) and 1 i32 return value(s) -unsupported function with invalid parameter or result type: 'add_something' +unsupported function with invalid parameter or result type: 'add_something' """ ) @@ -619,18 +644,18 @@ def test_wasmfilehandler_repr_64_2() -> None: == """Functions in wasm file with the uid 360e60c3b092ad735982ba49207f9c3250b111e5963fb630c69f85266172080b: function 'init' with 0 i64 parameter(s) and 0 i64 return value(s) function 'add_something' with 1 i64 parameter(s) and 1 i64 return value(s) -unsupported function with invalid parameter or result type: 'add_one' -unsupported function with invalid parameter or result type: 'multi' -unsupported function with invalid parameter or result type: 'add_two' -unsupported function with invalid parameter or result type: 'add_something_32' -unsupported function with invalid parameter or result type: 'add_eleven' -unsupported function with invalid parameter or result type: 'no_return' -unsupported function with invalid parameter or result type: 'no_parameters' -unsupported function with invalid parameter or result type: 'new_function' -unsupported function with invalid parameter or result type: 'mixed_up' -unsupported function with invalid parameter or result type: 'mixed_up_2' -unsupported function with invalid parameter or result type: 'mixed_up_3' -unsupported function with invalid parameter or result type: 'unse_internal' +unsupported function with invalid parameter or result type: 'add_one' +unsupported function with invalid parameter or result type: 'multi' +unsupported function with invalid parameter or result type: 'add_two' +unsupported function with invalid parameter or result type: 'add_something_32' +unsupported function with invalid parameter or result type: 'add_eleven' +unsupported function with invalid parameter or result type: 'no_return' +unsupported function with invalid parameter or result type: 'no_parameters' +unsupported function with invalid parameter or result type: 'new_function' +unsupported function with invalid parameter or result type: 'mixed_up' +unsupported function with invalid parameter or result type: 'mixed_up_2' +unsupported function with invalid parameter or result type: 'mixed_up_3' +unsupported function with invalid parameter or result type: 'unse_internal' """ ) @@ -658,7 +683,7 @@ def test_wasmfilehandler_multivalue_clang() -> None: == """Functions in wasm file with the uid 6f821422038eec251d2f4e6bf2b9a5717b18b5c96a8a8e01fb49f080d9610f6e: function '__wasm_call_ctors' with 0 i32 parameter(s) and 0 i32 return value(s) function 'init' with 0 i32 parameter(s) and 0 i32 return value(s) -unsupported function with invalid parameter or result type: 'divmod' +unsupported function with invalid parameter or result type: 'divmod' """ )