mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
* numeric.c (int_pow): fix previous nubu's commit.
* test/ruby/test_fixnum.rb: new test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b553a34c63
commit
a0d50fa3c4
3 changed files with 39 additions and 4 deletions
26
test/ruby/test_fixnum.rb
Normal file
26
test/ruby/test_fixnum.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'test/unit'
|
||||
|
||||
class TestFixnum < Test::Unit::TestCase
|
||||
def setup
|
||||
@verbose = $VERBOSE
|
||||
$VERBOSE = nil
|
||||
end
|
||||
|
||||
def teardown
|
||||
$VERBOSE = @verbose
|
||||
end
|
||||
|
||||
def test_pow
|
||||
[1, 2, 2**64, 2**63*3, 2**64*3].each do |y|
|
||||
[1, 3].each do |x|
|
||||
z1 = x**y
|
||||
z2 = (-x)**y
|
||||
if y % 2 == 1
|
||||
assert_equal(z2, -z1)
|
||||
else
|
||||
assert_equal(z2, z1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue