Debian Codegraph @

t/regression/boolean_copy.t

raw
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Fatal;
6 use lib 't/lib';
7 use lib 't/pvtlib';
8 use CleanEnv;
9
10 use BSON;
11 use boolean;
12
13 my $c = BSON->new;
14
15 # PERL-575 boolean values were references to each other, so if two were created
16 # identically, then changing one would change the other.
17
18 my $a = { "okay" => false, "name" => "fred0" };
19 my $b = { "okay" => false, "name" => "fred1" };
20
21 my $a_bin = $c->encode_one( $a );
22 my $b_bin = $c->encode_one( $b );
23
24 my @docs = ( map{ $c->decode_one( $_ ) } ( $a_bin, $b_bin ) );
25
26 is( exception { $_->{okay} = $_->{okay}->TO_JSON for @docs },
27 undef, "replacing one boolean doesn't affect another" );
28
29 done_testing;