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);
91 ok ($a++ eq '0', do { $a=undef; $a++ }, "postinc undef returns '0'");
94 ok (!defined($a--), do { $a=undef; $a-- }, "postdec undef returns undef");
96 # Verify that shared hash keys become unshared.
99 my ($orig, $suspect) = @_;
101 while (my ($key, $value) = each %$suspect) {
102 if (exists $orig->{$key}) {
103 if ($orig->{$key} ne $value) {
104 print "# key '$key' was '$orig->{$key}' now '$value'\n";
108 print "# key '$key' is '$orig->{$key}', unexpect.\n";
112 foreach (keys %$orig) {
113 next if (exists $suspect->{$_});
114 print "# key '$_' was '$orig->{$_}' now missing\n";
120 my (%orig) = my (%inc) = my (%dec) = my (%postinc) = my (%postdec)
121 = (1 => 1, ab => "ab");
122 my %up = (1=>2, ab => 'ac');
123 my %down = (1=>0, ab => -1);
125 foreach (keys %inc) {
129 ok ((defined $up and $up eq $ans), $up, $@);
132 check_same (\%orig, \%inc);
134 foreach (keys %dec) {
138 ok ((defined $down and $down eq $ans), $down, $@);
141 check_same (\%orig, \%dec);
143 foreach (keys %postinc) {
144 my $ans = $postinc{$_};
147 ok ((defined $up and $up eq $ans), $up, $@);
150 check_same (\%orig, \%postinc);
152 foreach (keys %postdec) {
153 my $ans = $postdec{$_};
156 ok ((defined $down and $down eq $ans), $down, $@);
159 check_same (\%orig, \%postdec);