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

ruby-changes:28014

From: akr <ko1@a...>
Date: Tue, 2 Apr 2013 19:26:20 +0900 (JST)
Subject: [ruby-changes:28014] akr:r40066 (trunk): * ext/-test-/num2int/num2int.c: Define utility methods

akr	2013-04-02 19:26:02 +0900 (Tue, 02 Apr 2013)

  New Revision: 40066

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

  Log:
    * ext/-test-/num2int/num2int.c: Define utility methods
      as module methods of Num2int.
    
    * test/-ext-/num2int/test_num2int.rb: Follow the above change.

  Modified files:
    trunk/ChangeLog
    trunk/ext/-test-/num2int/num2int.c
    trunk/test/-ext-/num2int/test_num2int.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40065)
+++ ChangeLog	(revision 40066)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Apr  2 19:24:26 2013  Tanaka Akira  <akr@f...>
+
+	* ext/-test-/num2int/num2int.c: Define utility methods
+	  as module methods of Num2int.
+
+	* test/-ext-/num2int/test_num2int.rb: Follow the above change.
+
 Tue Apr  2 18:49:01 2013  Tanaka Akira  <akr@f...>
 
 	* lib/securerandom.rb: Don't use Array#to_s.
Index: ext/-test-/num2int/num2int.c
===================================================================
--- ext/-test-/num2int/num2int.c	(revision 40065)
+++ ext/-test-/num2int/num2int.c	(revision 40066)
@@ -109,26 +109,28 @@ test_fix2ulong(VALUE obj, VALUE num) https://github.com/ruby/ruby/blob/trunk/ext/-test-/num2int/num2int.c#L109
 void
 Init_num2int(void)
 {
-    rb_define_global_function("NUM2SHORT", test_num2short, 1);
-    rb_define_global_function("NUM2USHORT", test_num2ushort, 1);
+    VALUE mNum2int = rb_define_module("Num2int");
 
-    rb_define_global_function("NUM2INT", test_num2int, 1);
-    rb_define_global_function("NUM2UINT", test_num2uint, 1);
+    rb_define_module_function(mNum2int, "NUM2SHORT", test_num2short, 1);
+    rb_define_module_function(mNum2int, "NUM2USHORT", test_num2ushort, 1);
 
-    rb_define_global_function("NUM2LONG", test_num2long, 1);
-    rb_define_global_function("NUM2ULONG", test_num2ulong, 1);
+    rb_define_module_function(mNum2int, "NUM2INT", test_num2int, 1);
+    rb_define_module_function(mNum2int, "NUM2UINT", test_num2uint, 1);
+
+    rb_define_module_function(mNum2int, "NUM2LONG", test_num2long, 1);
+    rb_define_module_function(mNum2int, "NUM2ULONG", test_num2ulong, 1);
 
 #ifdef HAVE_LONG_LONG
-    rb_define_global_function("NUM2LL", test_num2ll, 1);
-    rb_define_global_function("NUM2ULL", test_num2ull, 1);
+    rb_define_module_function(mNum2int, "NUM2LL", test_num2ll, 1);
+    rb_define_module_function(mNum2int, "NUM2ULL", test_num2ull, 1);
 #endif
 
-    rb_define_global_function("FIX2SHORT", test_fix2short, 1);
+    rb_define_module_function(mNum2int, "FIX2SHORT", test_fix2short, 1);
 
-    rb_define_global_function("FIX2INT", test_fix2int, 1);
-    rb_define_global_function("FIX2UINT", test_fix2uint, 1);
+    rb_define_module_function(mNum2int, "FIX2INT", test_fix2int, 1);
+    rb_define_module_function(mNum2int, "FIX2UINT", test_fix2uint, 1);
 
-    rb_define_global_function("FIX2LONG", test_fix2long, 1);
-    rb_define_global_function("FIX2ULONG", test_fix2ulong, 1);
+    rb_define_module_function(mNum2int, "FIX2LONG", test_fix2long, 1);
+    rb_define_module_function(mNum2int, "FIX2ULONG", test_fix2ulong, 1);
 }
 
Index: test/-ext-/num2int/test_num2int.rb
===================================================================
--- test/-ext-/num2int/test_num2int.rb	(revision 40065)
+++ test/-ext-/num2int/test_num2int.rb	(revision 40066)
@@ -36,7 +36,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L36
     mesg = "#{func}(#{arg.inspect})"
     out = nil
     assert_nothing_raised(mesg) {
-      out = Kernel.send(func, arg)
+      out = Num2int.send(func, arg)
     }
     assert_equal(exp, out, mesg)
   end
@@ -66,7 +66,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L66
 
   def assert_num2i_error_internal(func, arg)
     assert_raise(RangeError, "#{func}(#{arg.inspect})") {
-      Kernel.send(func, arg)
+      Num2int.send(func, arg)
     }
   end
 
@@ -97,7 +97,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L97
     mesg = "#{func}(#{arg.inspect})"
     out = nil
     assert_nothing_raised(mesg) {
-      out = Kernel.send(func, arg)
+      out = Num2int.send(func, arg)
     }
     assert_equal(exp, out, mesg)
   end
@@ -110,7 +110,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L110
 
   def assert_fix2i_error_internal(func, arg)
     assert_raise(RangeError, "#{func}(#{arg.inspect})") {
-      Kernel.send(func, arg)
+      Num2int.send(func, arg)
     }
   end
 
@@ -185,7 +185,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L185
     assert_num2i_success(:ll, FIXNUM_MIN-1)
     assert_num2i_success(:ll, FIXNUM_MAX)
     assert_num2i_success(:ll, FIXNUM_MAX+1)
-  end if defined?(Kernel.NUM2LL)
+  end if defined?(Num2int.NUM2LL)
 
   def test_num2ull
     assert_num2i_success(:ull, 0)
@@ -198,7 +198,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L198
     assert_num2i_success(:ull, FIXNUM_MIN-1, ULLONG_MAX-FIXNUM_MAX-1)
     assert_num2i_success(:ull, FIXNUM_MAX)
     assert_num2i_success(:ull, FIXNUM_MAX+1)
-  end if defined?(Kernel.NUM2ULL)
+  end if defined?(Num2int.NUM2ULL)
 
   def test_fix2short
     assert_fix2i_success(:short, 0)

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

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