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

ruby-changes:21486

From: nobu <ko1@a...>
Date: Thu, 27 Oct 2011 16:11:00 +0900 (JST)
Subject: [ruby-changes:21486] nobu:r33535 (trunk): * test/ruby/test_bignum.rb: ensure constants to be Bignum.

nobu	2011-10-27 16:10:49 +0900 (Thu, 27 Oct 2011)

  New Revision: 33535

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33535

  Log:
    * test/ruby/test_bignum.rb: ensure constants to be Bignum.

  Modified files:
    trunk/test/ruby/test_bignum.rb

Index: test/ruby/test_bignum.rb
===================================================================
--- test/ruby/test_bignum.rb	(revision 33534)
+++ test/ruby/test_bignum.rb	(revision 33535)
@@ -108,19 +108,35 @@
     assert_equal("-1777777777777777777777" ,-18446744073709551615.to_s(8))
   end
 
+  b = 2**64
+  b *= b until Bignum === b
 
-  T_ZERO = (2**32).coerce(0).first
-  T_ONE  = (2**32).coerce(1).first
-  T_MONE = (2**32).coerce(-1).first
-  T31  = 2**31   # 2147483648
-  T31P = T31 - 1 # 2147483647
-  T32  = 2**32   # 4294967296
-  T32P = T32 - 1 # 4294967295
-  T64  = 2**64   # 18446744073709551616
-  T64P = T64 - 1 # 18446744073709551615
-  T1024  = 2**1024
-  T1024P = T1024 - 1
+  T_ZERO = b.coerce(0).first
+  T_ONE  = b.coerce(1).first
+  T_MONE = b.coerce(-1).first
+  T31  = b.coerce(2**31).first   # 2147483648
+  T31P = b.coerce(T31 - 1).first # 2147483647
+  T32  = b.coerce(2**32).first   # 4294967296
+  T32P = b.coerce(T32 - 1).first # 4294967295
+  T64  = b.coerce(2**64).first   # 18446744073709551616
+  T64P = b.coerce(T64 - 1).first # 18446744073709551615
+  T1024  = b.coerce(2**1024).first
+  T1024P = b.coerce(T1024 - 1).first
 
+  def test_prepare
+    assert_instance_of(Bignum, T_ZERO)
+    assert_instance_of(Bignum, T_ONE)
+    assert_instance_of(Bignum, T_MONE)
+    assert_instance_of(Bignum, T31)
+    assert_instance_of(Bignum, T31P)
+    assert_instance_of(Bignum, T32)
+    assert_instance_of(Bignum, T32P)
+    assert_instance_of(Bignum, T64)
+    assert_instance_of(Bignum, T64P)
+    assert_instance_of(Bignum, T1024)
+    assert_instance_of(Bignum, T1024P)
+  end
+
   def test_big_2comp
     assert_equal("-4294967296", (~T32P).to_s)
     assert_equal("..f00000000", "%x" % -T32)

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

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