From a0d50fa3c494ea5afb98c05be049a0cde6fde28d Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 5 Jul 2007 07:38:41 +0000 Subject: * 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 --- test/ruby/test_fixnum.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/ruby/test_fixnum.rb (limited to 'test/ruby/test_fixnum.rb') diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb new file mode 100644 index 0000000000..57999d4b03 --- /dev/null +++ b/test/ruby/test_fixnum.rb @@ -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 -- cgit v1.2.3