-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for the factory module (#15)
This adds tests for the module `factory.py`
- Loading branch information
1 parent
fb75e71
commit 231968d
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from qadence2_ir import AST, AllocQubits, ir_compiler_factory | ||
from qadence2_ir.types import Alloc, Assign, Call, Load, Model, QuInstruct, Support | ||
|
||
from .conftest import InputTypeTest, IRBuilderTest | ||
|
||
|
||
def test_init(quantum_ast: AST, builder: IRBuilderTest) -> None: | ||
ir_compiler = ir_compiler_factory(builder) | ||
input_ = InputTypeTest(10, {"my-directive": False}, {"my-setting": 8}, quantum_ast) | ||
model = ir_compiler(input_) | ||
expected = Model( | ||
AllocQubits(10), | ||
{"x": Alloc(1, False)}, | ||
[ | ||
Assign("%0", Call("div", Load("x"), 3)), | ||
Assign("%1", Call("fn", Load("%0"), Load("x"))), | ||
QuInstruct("rx", Support((0,), (1,)), Load("%1")), | ||
], | ||
{"my-directive": False}, | ||
{"my-setting": 8}, | ||
) | ||
assert model == expected |