diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-20 14:26:33 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-20 14:26:33 +0000 |
commit | 744ccfbc14962920ff5e45da1e497276cdd19a80 (patch) | |
tree | c1b8dcfcf93f3c2be1c00e15660a559f60662400 | |
parent | 1717ce00e888f4423c092753c5a71b78272652eb (diff) | |
download | ruby-744ccfbc14962920ff5e45da1e497276cdd19a80.tar.gz ruby-744ccfbc14962920ff5e45da1e497276cdd19a80.tar.xz ruby-744ccfbc14962920ff5e45da1e497276cdd19a80.zip |
* test/ruby/test_array.rb: fix tests for 64bit CPU.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | test/ruby/test_array.rb | 22 |
2 files changed, 20 insertions, 6 deletions
@@ -1,3 +1,7 @@ +Tue May 20 23:26:05 2008 Yusuke Endoh <mame@tsg.ne.jp> + + * test/ruby/test_array.rb: fix tests for 64bit CPU. + Tue May 20 20:59:56 2008 NARUSE, Yui <naruse@ruby-lang.org> * ext/nkf/nkf-utf8/nkf.c (rb_nkf_convert) (nkf_enc_without_bom): diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 54d54e3c6..dd3d165c1 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1306,9 +1306,19 @@ class TestArray < Test::Unit::TestCase end end + LONGP = [127, 63, 31, 15, 7].map {|x| 2**x-1 }.find do |x| + begin + [].first(x) + rescue ArgumentError + true + rescue RangeError + false + end + end + def test_ary_new assert_raise(ArgumentError) { [].to_enum.first(-1) } - assert_raise(ArgumentError) { [].to_enum.first(2**31-1) } + assert_raise(ArgumentError) { [].to_enum.first(LONGP) } end def test_try_convert @@ -1321,7 +1331,7 @@ class TestArray < Test::Unit::TestCase assert_nothing_raised { Array.new { } } assert_equal([1, 2, 3], Array.new([1, 2, 3])) assert_raise(ArgumentError) { Array.new(-1, 1) } - assert_raise(ArgumentError) { Array.new(2**31-1, 1) } + assert_raise(ArgumentError) { Array.new(LONGP, 1) } assert_equal([1, 1, 1], Array.new(3, 1)) assert_equal([1, 1, 1], Array.new(3) { 1 }) assert_equal([1, 1, 1], Array.new(3, 1) { 1 }) @@ -1329,8 +1339,8 @@ class TestArray < Test::Unit::TestCase def test_aset assert_raise(IndexError) { [0][-2] = 1 } - assert_raise(ArgumentError) { [0][2**31-1] = 2 } - assert_raise(ArgumentError) { [0][2**30-1] = 3 } + assert_raise(ArgumentError) { [0][LONGP] = 2 } + assert_raise(ArgumentError) { [0][(LONGP + 1) / 2 - 1] = 2 } a = [0] a[2] = 4 assert_equal([0, nil, 4], a) @@ -1466,11 +1476,11 @@ class TestArray < Test::Unit::TestCase end def test_fill2 - assert_raise(ArgumentError) { [].fill(0, 1, 2**31-1) } + assert_raise(ArgumentError) { [].fill(0, 1, LONGP) } end def test_times - assert_raise(ArgumentError) { [0, 0, 0, 0] * (2**29) } + assert_raise(ArgumentError) { [0, 0, 0, 0] * ((LONGP + 1) / 4) } end def test_equal |