-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d22aabe
commit 0a9655b
Showing
1 changed file
with
25 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,39 +1,49 @@ | ||
from qupsy.language import Div, GateCmd, HoleCmd, Integer, Mul, Pgm, Ry, SeqCmd | ||
|
||
|
||
def test_pgm_create_with_empty_body(): | ||
def test_pgm(): | ||
pgm = Pgm("n") | ||
assert isinstance(pgm.body, HoleCmd) | ||
|
||
|
||
def test_pgm_cost0(): | ||
def test_seq_cmd(): | ||
seq = SeqCmd() | ||
assert isinstance(seq.pre, HoleCmd) | ||
assert isinstance(seq.post, HoleCmd) | ||
|
||
|
||
def test_str(): | ||
pgm = GateCmd(Ry(Integer(0), Integer(1), Integer(3))) | ||
assert str(pgm) == "Ry(0, 1, 3)" | ||
|
||
|
||
def test_cost0(): | ||
pgm = Pgm("n") | ||
assert pgm.cost == pgm.body.cost | ||
|
||
|
||
def test_pgm_cost1(): | ||
def test_cost1(): | ||
pgm = Pgm("n", GateCmd(Ry(Integer(0), Integer(1), Integer(3)))) | ||
assert pgm.cost == 2 | ||
|
||
|
||
def test_pgm_depth(): | ||
def test_depth(): | ||
pgm = Pgm("n") | ||
assert pgm.depth == pgm.body.depth | ||
|
||
|
||
def test_seq_cmd_wo_pre_and_post(): | ||
seq = SeqCmd() | ||
assert isinstance(seq.pre, HoleCmd) | ||
assert isinstance(seq.post, HoleCmd) | ||
def test_children(): | ||
pgm = Div(Integer(2), Integer(3)) | ||
children = pgm.children | ||
assert children == [Integer(2), Integer(3)] | ||
|
||
|
||
def test_terminated(): | ||
pgm = Pgm("n") | ||
assert pgm.terminated == False | ||
|
||
|
||
def test_pgm_call(): | ||
def test_call(): | ||
pgm = Mul(Integer(2), Integer(3)) | ||
res = pgm.__call__({"n": 5}) | ||
assert res == 6 | ||
|
||
|
||
def test_pgm_children(): | ||
pgm = Div(Integer(2), Integer(3)) | ||
children = pgm.children | ||
assert children == [Integer(2), Integer(3)] |