Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #20 from Siddhant/master
toss sub 'tryeq' which is better written as 'is ..., ..., ...;'
  • Loading branch information
GlitchMr committed May 27, 2012
2 parents 91d3ea5 + 7b703ae commit 1db7629
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions S03-operators/overflow.t
Expand Up @@ -122,11 +122,6 @@ is($b, -(++$a), 'test oder of predecrement in -(++$a)');
is -2147483640 + -10, -2147483650;
}

sub tryeq ($lhs, $rhs) {
ok($lhs == $rhs, "$lhs == $rhs");
}


#?DOES 1
sub tryeq_sloppy ($lhs, $rhs, $todo1 = '') {
my $todo = $todo1; # TODO is rw
Expand All @@ -153,9 +148,9 @@ sub tryeq_sloppy ($lhs, $rhs, $todo1 = '') {
}

{
tryeq 2147483648 - 0, 2147483648;
tryeq -2147483648 - 0, -2147483648;
tryeq 2000000000 - 4000000000, -2000000000;
is 2147483648 - 0, 2147483648, '2147483648 = 2147483648';
is -2147483648 - 0, -2147483648, '-2147483648 = -2147483648';
is 2000000000 - 4000000000, -2000000000, '-2000000000 = -2000000000';
}

# Believe it or not, this one overflows on 32-bit Rakduo as of 3/8/2010.
Expand All @@ -175,26 +170,26 @@ sub tryeq_sloppy ($lhs, $rhs, $todo1 = '') {
# On a 32 bit machine, if the i_multiply op is used, you will probably get
# -167772160. It's actually undefined behaviour, so anything may happen.
my $int = ($n % 1000) * 167772160;
tryeq $int, 21307064320;
is $int, 21307064320, "$int = 21307064320";

}

{
tryeq -1 - -2147483648, 2147483647;
tryeq 2 - -2147483648, 2147483650;
is -1 - -2147483648, 2147483647, '2147483647 = 2147483647';
is 2 - -2147483648, 2147483650, '2147483650 = 2147483650';

tryeq 4294967294 - 3, 4294967291;
tryeq -2147483648 - -1, -2147483647;
is 4294967294 - 3, 4294967291, '4294967291 = 4294967291';
is -2147483648 - -1, -2147483647, '-2147483647 = -2147483647';

# IV - IV promote to UV
tryeq 2147483647 - -1, 2147483648;
tryeq 2147483647 - -2147483648, 4294967295;
is 2147483647 - -1, 2147483648, '2147483648 = 2147483648';
is 2147483647 - -2147483648, 4294967295, '4294967295 = 4294967295';
# UV - IV promote to NV
tryeq 4294967294 - -3, 4294967297;
is 4294967294 - -3, 4294967297, '4294967297 = 4294967297';
# IV - IV promote to NV
tryeq -2147483648 - +1, -2147483649;
is -2147483648 - +1, -2147483649, '-2147483649 = -2147483649';
# UV - UV promote to IV
tryeq 2147483648 - 2147483650, -2;
is 2147483648 - 2147483650, -2, '-2 = -2';
}

# check with 0xFFFF and 0xFFFF
Expand Down Expand Up @@ -268,4 +263,4 @@ sub tryeq_sloppy ($lhs, $rhs, $todo1 = '') {
}


# vim: ft=perl6
# vim: ft=perl6

0 comments on commit 1db7629

Please sign in to comment.