[前][次][番号順一覧][スレッド一覧]

ruby-changes:5001

From: ko1@a...
Date: Tue, 20 May 2008 23:26:48 +0900 (JST)
Subject: [ruby-changes:5001] mame - Ruby:r16494 (trunk): * test/ruby/test_array.rb: fix tests for 64bit CPU.

mame	2008-05-20 23:26:33 +0900 (Tue, 20 May 2008)

  New Revision: 16494

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_array.rb

  Log:
    * test/ruby/test_array.rb: fix tests for 64bit CPU.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16494&r2=16493&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_array.rb?r1=16494&r2=16493&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16493)
+++ ChangeLog	(revision 16494)
@@ -1,3 +1,7 @@
+Tue May 20 23:26:05 2008  Yusuke Endoh  <mame@t...>
+
+	* test/ruby/test_array.rb: fix tests for 64bit CPU.
+
 Tue May 20 20:59:56 2008  NARUSE, Yui  <naruse@r...>
 
 	* ext/nkf/nkf-utf8/nkf.c (rb_nkf_convert) (nkf_enc_without_bom):
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 16493)
+++ test/ruby/test_array.rb	(revision 16494)
@@ -1306,9 +1306,19 @@
     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 @@
     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 @@
 
   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 @@
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]