Skip to content

Commit 115c75c

Browse files
committed
Tests for if/unless on IVal.
1 parent 6980843 commit 115c75c

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

t/qast/qast.t

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use QRegex;
22

3-
plan(8);
3+
plan(15);
44

55
# Following a test infrastructure.
66
sub compile_qast($qast) {
@@ -104,3 +104,72 @@ test_qast_result(
104104
ok($r[0].m eq 'a', 'op list works (first elem)');
105105
ok($r[1].m eq 'b', 'op list works (second elem)');
106106
});
107+
108+
is_qast(
109+
QAST::Block.new(
110+
QAST::Op.new(
111+
:op('if'),
112+
QAST::IVal.new(:value(1)),
113+
QAST::IVal.new(:value(2)),
114+
QAST::IVal.new(:value(3))
115+
)
116+
),
117+
2,
118+
'if with IVal, 3-operand');
119+
120+
is_qast(
121+
QAST::Block.new(
122+
QAST::Op.new(
123+
:op('if'),
124+
QAST::IVal.new(:value(0)),
125+
QAST::IVal.new(:value(2)),
126+
QAST::IVal.new(:value(3))
127+
)
128+
),
129+
3,
130+
'if with IVal, 3-operand');
131+
132+
is_qast(
133+
QAST::Block.new(
134+
QAST::Op.new(
135+
:op('if'),
136+
QAST::IVal.new(:value(1)),
137+
QAST::IVal.new(:value(2))
138+
)
139+
),
140+
2,
141+
'if with IVal, 2-operand');
142+
143+
is_qast(
144+
QAST::Block.new(
145+
QAST::Op.new(
146+
:op('if'),
147+
QAST::IVal.new(:value(0)),
148+
QAST::IVal.new(:value(2))
149+
)
150+
),
151+
0,
152+
'if with IVal, 2-operand');
153+
154+
is_qast(
155+
QAST::Block.new(
156+
QAST::Op.new(
157+
:op('unless'),
158+
QAST::IVal.new(:value(1)),
159+
QAST::IVal.new(:value(2))
160+
)
161+
),
162+
1,
163+
'unless with IVal');
164+
165+
is_qast(
166+
QAST::Block.new(
167+
QAST::Op.new(
168+
:op('unless'),
169+
QAST::IVal.new(:value(0)),
170+
QAST::IVal.new(:value(2))
171+
)
172+
),
173+
2,
174+
'unless with IVal');
175+

0 commit comments

Comments
 (0)