Skip to content

Commit f185227

Browse files
committed
refactor test to loadfile instead of loads
1 parent 551723e commit f185227

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/bloqade/qasm2/parse/lowering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def loadfile(
101101
file: str | pathlib.Path,
102102
*,
103103
kernel_name: str | None = None,
104-
returns: list[str] | None = None,
104+
returns: str | None = None,
105105
globals: dict[str, Any] | None = None,
106106
lineno_offset: int = 0,
107107
col_offset: int = 0,

test/qasm2/test_lowering.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pathlib
2+
import tempfile
13
import textwrap
24

35
from kirin.dialects import func
@@ -27,9 +29,16 @@ def test_run_lowering():
2729
code.print()
2830

2931

30-
def test_loads():
32+
def test_loadfile():
3133

32-
kernel = QASM2(qasm2.main).loads(lines, "test", returns="c")
33-
qasm2.main.run_pass(kernel) # type: ignore
34-
assert isinstance((ret := kernel.callable_region.blocks[0].last_stmt), func.Return)
35-
assert ret.value.type.is_equal(qasm2.types.CRegType)
34+
with tempfile.TemporaryDirectory() as tmp_dir:
35+
with open(f"{tmp_dir}/test.qasm", "w") as f:
36+
f.write(lines)
37+
38+
file = pathlib.Path(f"{tmp_dir}/test.qasm")
39+
kernel = QASM2(qasm2.main).loadfile(file, returns="c")
40+
41+
assert isinstance(
42+
(ret := kernel.callable_region.blocks[0].last_stmt), func.Return
43+
)
44+
assert ret.value.type.is_equal(qasm2.types.CRegType)

0 commit comments

Comments
 (0)