10 my ($pass, $wrong, $err) = @_;
13 $test = $test + 1; # Would be doubleplusbad to use ++ in the ++ test.
18 print "not ok $test # $err\n";
21 $wrong = ", got $wrong";
25 printf "not ok $test # line %d$wrong\n", (caller)[2];
32 # Verify that addition/subtraction properly upgrade to doubles.
33 # These tests are only significant on machines with 32 bit longs,
34 # and two's complement negation, but shouldn't fail anywhere.
38 ok ($a == 2147483648, $a);
42 ok ($a == 2147483648, $a);
46 ok ($a == 2147483648, $a);
50 ok ($a == -2147483649, $a);
54 ok ($a == -2147483649, $a);
58 ok ($a == -2147483649, $a);
63 ok ($a == -2147483649, $a);
68 ok ($a == -2147483649, $a);
73 ok ($a == -2147483649, $a);
88 ok ($b == -(++$a), $a);
90 # Verify that shared hash keys become unshared.
93 my ($orig, $suspect) = @_;
95 while (my ($key, $value) = each %$suspect) {
96 if (exists $orig->{$key}) {
97 if ($orig->{$key} ne $value) {
98 print "# key '$key' was '$orig->{$key}' now '$value'\n";
102 print "# key '$key' is '$orig->{$key}', unexpect.\n";
106 foreach (keys %$orig) {
107 next if (exists $suspect->{$_});
108 print "# key '$_' was '$orig->{$_}' now missing\n";
114 my (%orig) = my (%inc) = my (%dec) = my (%postinc) = my (%postdec)
115 = (1 => 1, ab => "ab");
116 my %up = (1=>2, ab => 'ac');
117 my %down = (1=>0, ab => -1);
119 foreach (keys %inc) {
123 ok ((defined $up and $up eq $ans), $up, $@);
126 check_same (\%orig, \%inc);
128 foreach (keys %dec) {
132 ok ((defined $down and $down eq $ans), $down, $@);
135 check_same (\%orig, \%dec);
137 foreach (keys %postinc) {
138 my $ans = $postinc{$_};
141 ok ((defined $up and $up eq $ans), $up, $@);
144 check_same (\%orig, \%postinc);
146 foreach (keys %postdec) {
147 my $ans = $postdec{$_};
150 ok ((defined $down and $down eq $ans), $down, $@);
153 check_same (\%orig, \%postdec);