Skip to content

Commit 7ff8f08

Browse files
committed
Test nohandler with the for op
1 parent cb2c35c commit 7ff8f08

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

t/qast/01-qast.t

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

3-
plan(124);
3+
plan(125);
44

55
# Following a test infrastructure.
66
sub compile_qast($qast) {
@@ -2032,3 +2032,61 @@ is_qast(
20322032
),
20332033
3,
20342034
'while loop nohandler');
2035+
2036+
{
2037+
my sub with_arity($arity, $block) {
2038+
$block.arity($arity);
2039+
$block;
2040+
}
2041+
2042+
is_qast(
2043+
QAST::Block.new(
2044+
QAST::Op.new(
2045+
:op<bind>,
2046+
QAST::Var.new( :name('$i'), :scope<lexical>, :decl<var>, :returns(int) ),
2047+
QAST::IVal.new( :value(10) )
2048+
),
2049+
QAST::Op.new(
2050+
:op<while>,
2051+
QAST::Var.new( :name('$i'), :scope<lexical> ),
2052+
QAST::Stmts.new(
2053+
QAST::Op.new(
2054+
:op<bind>,
2055+
QAST::Var.new( :name('$i'), :scope<lexical> ),
2056+
QAST::Op.new(
2057+
:op<sub_i>,
2058+
QAST::Var.new( :name('$i'), :scope<lexical> ),
2059+
QAST::IVal.new( :value(1) )
2060+
)
2061+
),
2062+
QAST::Op.new(
2063+
:op<for>,
2064+
QAST::IVal.new( :value(1), :named('nohandler') ),
2065+
QAST::Op.new(
2066+
:op<list>,
2067+
QAST::IVal.new( :value(3) ),
2068+
QAST::IVal.new( :value(7) ),
2069+
QAST::IVal.new( :value(20) )
2070+
),
2071+
with_arity(1, QAST::Block.new(
2072+
:blocktype<immediate>,
2073+
QAST::Op.new(
2074+
:op<if>,
2075+
QAST::Op.new(
2076+
:op<iseq_i>,
2077+
QAST::Var.new( :name('$j'), :scope<lexical>, :decl<param> ),
2078+
QAST::Var.new( :name('$i'), :scope<lexical> )
2079+
),
2080+
QAST::Op.new( :op<control>, :name<last> )
2081+
),
2082+
QAST::Op.new(:op<null>)
2083+
))
2084+
)
2085+
)
2086+
),
2087+
QAST::Var.new( :name('$i'), :scope('lexical') ),
2088+
),
2089+
7,
2090+
'for loop nohandler');
2091+
2092+
}

0 commit comments

Comments
 (0)