Skip to content

Commit 00660af

Browse files
committed
Add test of logical ops
This is one bad case of an incorrect fixing of `||` logic. It says 0, which should be 200. Add this test to prevent regressions from happening.
1 parent 0a5e03a commit 00660af

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

t/nqp/012-logical.t

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# check '||', '&&', and '//'
44

5-
plan(16);
5+
plan(17);
66

77
my $or_no_branch := 1;
88
$or_no_branch || ( $or_no_branch := 0 );
@@ -44,6 +44,14 @@ ok(nqp::islist(nqp::xor(0, 0.0, :false("150"), nqp::list())), "when all the argu
4444

4545
is(nqp::xor('', 'hi', :false("150")), 'hi', 'xor returns the only true argument even if there is a :false pased');
4646

47-
my $foo := 42;
48-
my int $bar := $foo || 200;
49-
is($bar, 42, '|| when expecting an int');
47+
{
48+
my $foo := 42;
49+
my int $bar := $foo || 200;
50+
is($bar, 42, '|| when expecting an int');
51+
}
52+
53+
{
54+
my $foo := 0;
55+
my int $bar := $foo || 200;
56+
is($bar, 200, '|| when expecting an int');
57+
}

0 commit comments

Comments
 (0)