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

ruby-changes:42800

From: akr <ko1@a...>
Date: Mon, 2 May 2016 00:05:09 +0900 (JST)
Subject: [ruby-changes:42800] akr:r54874 (trunk): test/lib/test/unit/assertions.rb defines assert_fixnum and assert_bignum.

akr	2016-05-02 01:01:36 +0900 (Mon, 02 May 2016)

  New Revision: 54874

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54874

  Log:
    test/lib/test/unit/assertions.rb defines assert_fixnum and assert_bignum.
    
    * test/lib/test/unit/assertions.rb (assert_fixnum): Defined.
      (assert_bignum): Defined.
    
    * test/ruby/test_bignum.rb: Use assert_bignum.
    
    * test/ruby/test_integer_comb.rb: Use assert_fixnum and assert_bignum.
    
    * test/ruby/test_optimization.rb: Ditto.

  Modified files:
    trunk/ChangeLog
    trunk/test/lib/test/unit/assertions.rb
    trunk/test/ruby/test_bignum.rb
    trunk/test/ruby/test_integer_comb.rb
    trunk/test/ruby/test_optimization.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54873)
+++ ChangeLog	(revision 54874)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May  2 01:00:04 2016  Tanaka Akira  <akr@f...>
+
+	* test/lib/test/unit/assertions.rb (assert_fixnum): Defined.
+	  (assert_bignum): Defined.
+
+	* test/ruby/test_bignum.rb: Use assert_bignum.
+
+	* test/ruby/test_integer_comb.rb: Use assert_fixnum and assert_bignum.
+
+	* test/ruby/test_optimization.rb: Ditto.
+
 Mon May  2 00:41:53 2016  Tanaka Akira  <akr@f...>
 
 	* vm_trace.c (recalc_remove_ruby_vm_event_flags): Add a cast to
Index: test/lib/test/unit/assertions.rb
===================================================================
--- test/lib/test/unit/assertions.rb	(revision 54873)
+++ test/lib/test/unit/assertions.rb	(revision 54874)
@@ -771,6 +771,14 @@ eom https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit/assertions.rb#L771
         values
       end
 
+      def assert_fixnum(v, msg=nil)
+        assert_instance_of(Fixnum, v, msg)
+      end
+
+      def assert_bignum(v, msg=nil)
+        assert_instance_of(Bignum, v, msg)
+      end
+
       class << (AssertFile = Struct.new(:failure_message).new)
         include Assertions
         def assert_file_predicate(predicate, *args)
Index: test/ruby/test_integer_comb.rb
===================================================================
--- test/ruby/test_integer_comb.rb	(revision 54873)
+++ test/ruby/test_integer_comb.rb	(revision 54874)
@@ -114,17 +114,17 @@ class TestIntegerComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_integer_comb.rb#L114
   FIXNUM_MAX = Integer::FIXNUM_MAX
 
   def test_fixnum_range
-    assert_instance_of(Bignum, FIXNUM_MIN-1)
-    assert_instance_of(Fixnum, FIXNUM_MIN)
-    assert_instance_of(Fixnum, FIXNUM_MAX)
-    assert_instance_of(Bignum, FIXNUM_MAX+1)
+    assert_bignum(FIXNUM_MIN-1)
+    assert_fixnum(FIXNUM_MIN)
+    assert_fixnum(FIXNUM_MAX)
+    assert_bignum(FIXNUM_MAX+1)
   end
 
   def check_class(n)
     if FIXNUM_MIN <= n && n <= FIXNUM_MAX
-      assert_instance_of(Fixnum, n)
+      assert_fixnum(n)
     else
-      assert_instance_of(Bignum, n)
+      assert_bignum(n)
     end
   end
 
Index: test/ruby/test_bignum.rb
===================================================================
--- test/ruby/test_bignum.rb	(revision 54873)
+++ test/ruby/test_bignum.rb	(revision 54874)
@@ -51,18 +51,18 @@ class TestBignum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_bignum.rb#L51
   end
 
   def test_prepare
-    assert_instance_of(Bignum, @big)
-    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)
+    assert_bignum(@big)
+    assert_bignum(T_ZERO)
+    assert_bignum(T_ONE)
+    assert_bignum(T_MONE)
+    assert_bignum(T31)
+    assert_bignum(T31P)
+    assert_bignum(T32)
+    assert_bignum(T32P)
+    assert_bignum(T64)
+    assert_bignum(T64P)
+    assert_bignum(T1024)
+    assert_bignum(T1024P)
   end
 
   def test_bignum
@@ -469,7 +469,7 @@ class TestBignum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_bignum.rb#L469
     assert_raise(TypeError, ArgumentError) { T32**"foo" }
 
     feature3429 = '[ruby-core:30735]'
-    assert_instance_of(Bignum, (2 ** 7830457), feature3429)
+    assert_bignum((2 ** 7830457), feature3429)
   end
 
   def test_and
Index: test/ruby/test_optimization.rb
===================================================================
--- test/ruby/test_optimization.rb	(revision 54873)
+++ test/ruby/test_optimization.rb	(revision 54874)
@@ -25,8 +25,8 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L25
   def test_fixnum_plus
     a, b = 1, 2
     assert_equal 3, a + b
-    assert_instance_of Fixnum, FIXNUM_MAX
-    assert_instance_of Bignum, FIXNUM_MAX + 1
+    assert_fixnum FIXNUM_MAX
+    assert_bignum FIXNUM_MAX + 1
 
     assert_equal 21, 10 + 11
     assert_redefine_method('Fixnum', '+', 'assert_equal 11, 10 + 11')
@@ -34,8 +34,8 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L34
 
   def test_fixnum_minus
     assert_equal 5, 8 - 3
-    assert_instance_of Fixnum, FIXNUM_MIN
-    assert_instance_of Bignum, FIXNUM_MIN - 1
+    assert_fixnum FIXNUM_MIN
+    assert_bignum FIXNUM_MIN - 1
 
     assert_equal 5, 8 - 3
     assert_redefine_method('Fixnum', '-', 'assert_equal 3, 8 - 3')

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

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