Skip to content

Commit 7b23f8e

Browse files
committed
Test repeat while ... -> $cond {...}
1 parent 14db32e commit 7b23f8e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

t/nqp/014-while.t

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# while, until statements
22

3-
plan(16);
3+
plan(20);
44

55
my $a; my $sum;
66

@@ -105,3 +105,26 @@ while $str -> $got {
105105
is($got, 'hello there', 'regression test for a bug in type conversion');
106106
$str := '';
107107
}
108+
109+
my $x := 0;
110+
repeat until $x >= 2 -> $another_x {
111+
if $x == 0 {
112+
ok(nqp::isnull($another_x), 'repeat until -> get null before condition');
113+
} else {
114+
is($another_x, 0, 'repeat until -> gets condition');
115+
}
116+
$x := $x + 1;
117+
}
118+
119+
sub cond($y) {
120+
$y == 1 ?? 100 !! 0;
121+
}
122+
my $y := 0;
123+
repeat while cond($y) -> $cond {
124+
if $y == 0 {
125+
ok(nqp::isnull($cond), 'repeat while -> get null before condition');
126+
} else {
127+
is($cond, 100, 'repeat while -> gets condition');
128+
}
129+
$y := $y + 1;
130+
}

0 commit comments

Comments
 (0)