Skip to content

Commit

Permalink
Add a unit test that checks we didn't break booleans with the new COW…
Browse files Browse the repository at this point in the history
… static const behaviour
  • Loading branch information
leonerd committed Aug 22, 2021
1 parent 1841f96 commit ed90470
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -5830,6 +5830,7 @@ t/op/auto.t See if autoincrement et all work
t/op/avhv.t See if pseudo-hashes work
t/op/bless.t See if bless works
t/op/blocks.t See if BEGIN and friends work
t/op/bool.t Check misc details of boolean values
t/op/bop.t See if bitops work
t/op/caller.pl Tests shared between caller.t and XS op.t
t/op/caller.t See if caller() works
Expand Down
37 changes: 37 additions & 0 deletions t/op/bool.t
@@ -0,0 +1,37 @@
#!./perl

BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
}

use strict;
use warnings;

my $truevar = (5 == 5);
my $falsevar = (5 == 6);

cmp_ok($truevar, '==', 1);
cmp_ok($truevar, 'eq', "1");

cmp_ok($falsevar, '==', 0);
cmp_ok($falsevar, 'eq', "");

{
# Check that boolean COW string buffer is safe to copy into new SVs and
# doesn't get corrupted by inplace mutations
my $x = $truevar;
$x =~ s/1/t/;

cmp_ok($x, 'eq', "t");
cmp_ok($truevar, 'eq', "1");

my $y = $truevar;
substr($y, 0, 1, "T");

cmp_ok($y, 'eq', "T");
cmp_ok($truevar, 'eq', "1");
}

done_testing();

0 comments on commit ed90470

Please sign in to comment.