mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_array.rb: fix tests for 64bit CPU.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5eb4d70c5f
commit
c051ec7bc0
2 changed files with 20 additions and 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>
|
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):
|
* ext/nkf/nkf-utf8/nkf.c (rb_nkf_convert) (nkf_enc_without_bom):
|
||||||
|
|
|
@ -1306,9 +1306,19 @@ class TestArray < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
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
|
def test_ary_new
|
||||||
assert_raise(ArgumentError) { [].to_enum.first(-1) }
|
assert_raise(ArgumentError) { [].to_enum.first(-1) }
|
||||||
assert_raise(ArgumentError) { [].to_enum.first(2**31-1) }
|
assert_raise(ArgumentError) { [].to_enum.first(LONGP) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_try_convert
|
def test_try_convert
|
||||||
|
@ -1321,7 +1331,7 @@ class TestArray < Test::Unit::TestCase
|
||||||
assert_nothing_raised { Array.new { } }
|
assert_nothing_raised { Array.new { } }
|
||||||
assert_equal([1, 2, 3], Array.new([1, 2, 3]))
|
assert_equal([1, 2, 3], Array.new([1, 2, 3]))
|
||||||
assert_raise(ArgumentError) { Array.new(-1, 1) }
|
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 })
|
assert_equal([1, 1, 1], Array.new(3) { 1 })
|
||||||
assert_equal([1, 1, 1], Array.new(3, 1) { 1 })
|
assert_equal([1, 1, 1], Array.new(3, 1) { 1 })
|
||||||
|
@ -1329,8 +1339,8 @@ class TestArray < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_aset
|
def test_aset
|
||||||
assert_raise(IndexError) { [0][-2] = 1 }
|
assert_raise(IndexError) { [0][-2] = 1 }
|
||||||
assert_raise(ArgumentError) { [0][2**31-1] = 2 }
|
assert_raise(ArgumentError) { [0][LONGP] = 2 }
|
||||||
assert_raise(ArgumentError) { [0][2**30-1] = 3 }
|
assert_raise(ArgumentError) { [0][(LONGP + 1) / 2 - 1] = 2 }
|
||||||
a = [0]
|
a = [0]
|
||||||
a[2] = 4
|
a[2] = 4
|
||||||
assert_equal([0, nil, 4], a)
|
assert_equal([0, nil, 4], a)
|
||||||
|
@ -1466,11 +1476,11 @@ class TestArray < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fill2
|
def test_fill2
|
||||||
assert_raise(ArgumentError) { [].fill(0, 1, 2**31-1) }
|
assert_raise(ArgumentError) { [].fill(0, 1, LONGP) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_times
|
def test_times
|
||||||
assert_raise(ArgumentError) { [0, 0, 0, 0] * (2**29) }
|
assert_raise(ArgumentError) { [0, 0, 0, 0] * ((LONGP + 1) / 4) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equal
|
def test_equal
|
||||||
|
|
Loading…
Add table
Reference in a new issue