From 6d0c59f156da08a6a669a3187f86b424ce147626 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 2 Apr 2013 10:26:02 +0000 Subject: * ext/-test-/num2int/num2int.c: Define utility methods as module methods of Num2int. * test/-ext-/num2int/test_num2int.rb: Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/-test-/num2int/num2int.c | 28 +++++++++++++++------------- test/-ext-/num2int/test_num2int.rb | 12 ++++++------ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9b208df1e..a5fa64ed24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Apr 2 19:24:26 2013 Tanaka Akira + + * 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 * lib/securerandom.rb: Don't use Array#to_s. diff --git a/ext/-test-/num2int/num2int.c b/ext/-test-/num2int/num2int.c index be4c265895..3aec3ccf3b 100644 --- a/ext/-test-/num2int/num2int.c +++ b/ext/-test-/num2int/num2int.c @@ -109,26 +109,28 @@ test_fix2ulong(VALUE obj, VALUE num) 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); } diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb index f59c64c6b9..a75290025c 100644 --- a/test/-ext-/num2int/test_num2int.rb +++ b/test/-ext-/num2int/test_num2int.rb @@ -36,7 +36,7 @@ class TestNum2int < Test::Unit::TestCase 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 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 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 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 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 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) -- cgit v1.2.3