diff options
author | Andy Lester <andy@petdance.com> | 2003-07-23 11:38:35 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-07-24 13:08:50 +0000 |
commit | 1d296f1cbe6353bca53c99095d0fa4c3d9dcc0fb (patch) | |
tree | ea263cfb38327ef9d89cbb6bb08e54c7906e5790 /t | |
parent | 8fc7bb1c7604bebd186017cc94c49e7d29fbd334 (diff) | |
download | perl-1d296f1cbe6353bca53c99095d0fa4c3d9dcc0fb.tar.gz |
PATCH: More edge tests on t/op/pow.t
Message-ID: <20030723213834.GA20468@petdance.com>
p4raw-id: //depot/perl@20201
Diffstat (limited to 't')
-rw-r--r-- | t/op/pow.t | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/t/op/pow.t b/t/op/pow.t index 4342b1301e..9dd7780cfc 100644 --- a/t/op/pow.t +++ b/t/op/pow.t @@ -22,11 +22,28 @@ my @pow = ([3,30,1e-14], my $tests; $tests += $_->[1] foreach @pow; -plan tests => 2 + $bits_in_uv + $tests; +plan tests => 13 + $bits_in_uv + $tests; -# This gave positive 27 before change #20167 +# (-3)**3 gave 27 instead of -27 before change #20167. +# Let's test the other similar edge cases, too. +is((-3)**0, 1, "negative ** 0 = 1"); +is((-3)**1, -3, "negative ** 1 = self"); +is((-3)**2, 9, "negative ** 2 = positive"); is((-3)**3, -27, "(negative int) ** (odd power) is negative"); +# Positives shouldn't be a problem +is(3**0, 1, "positive ** 0 = 1"); +is(3**1, 3, "positive ** 1 = self"); +is(3**2, 9, "positive ** 2 = positive"); +is(3**3, 27, "(positive int) ** (odd power) is positive"); + +# And test order of operations while we're at it +is(-3**0, -1); +is(-3**1, -3); +is(-3**2, -9); +is(-3**3, -27); + + # Ought to be 32, 64, 36 or something like that. my $remainder = $bits_in_uv & 3; |