Skip to content

Commit 51585c8

Browse files
committed
Test nqp::ifnull.
1 parent 215eafd commit 51585c8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

t/nqp/88-more-if-tests.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plan(7);
1+
plan(10);
22
my $foo := 0;
33
1 if $foo++;
44
ok($foo == 1, "the if condition is evaluated once");
@@ -36,3 +36,12 @@ if side-effect() -> $value {
3636

3737
ok($count == 10, "side effect happens once");
3838

39+
my $log := '';
40+
sub log($msg, $value) {
41+
$log := $log ~ $msg;
42+
$value;
43+
}
44+
45+
ok(nqp::ifnull(log('a', nqp::null()), log('b', 'value1')) eq 'value1', 'ifnull with null');
46+
ok(nqp::ifnull(log('c', 'value2'), log('d', 'value3')) eq 'value2', 'ifnull without null');
47+
ok($log eq 'abc', 'only the right things are evaled');

0 commit comments

Comments
 (0)