Move `Kernel#send` to `mruby-metaprog` gem.
But `BasicObject#__send__` is still available from the core.
MODIFY
mrbgems/mruby-eval/test/eval.rb
mrbgems/mruby-eval/test/eval.rb
@@ -34,7 +34,7 @@ assert('Kernel.eval', '15.3.1.2.3') do
}
assert_equal(2) {
a = 10
- Kernel.eval 'def f(a); b=a.send(:+, 1); end'
+ Kernel.eval 'def f(a); b=a+1; end'
f(1)
}
end

MODIFY
mrbgems/mruby-metaprog/src/metaprog.c
mrbgems/mruby-metaprog/src/metaprog.c
@@ -680,6 +680,7 @@ mrb_mruby_metaprog_gem_init(mrb_state* mrb)
mrb_define_method(mrb, krn, "public_methods", mrb_obj_public_methods, MRB_ARGS_OPT(1)); /* 15.3.1.3.38 */
mrb_define_method(mrb, krn, "singleton_methods", mrb_obj_singleton_methods_m, MRB_ARGS_OPT(1)); /* 15.3.1.3.45 */
mrb_define_method(mrb, krn, "define_singleton_method", mod_define_singleton_method, MRB_ARGS_ANY());
+ mrb_define_method(mrb, krn, "send", mrb_f_send, MRB_ARGS_ANY()); /* 15.3.1.3.44 */
mrb_define_method(mrb, mod, "class_variables", mrb_mod_class_variables, MRB_ARGS_NONE()); /* 15.2.2.4.19 */
mrb_define_method(mrb, mod, "remove_class_variable", mrb_mod_remove_cvar, MRB_ARGS_REQ(1)); /* 15.2.2.4.39 */

MODIFY
mrbgems/mruby-metaprog/test/metaprog.rb
mrbgems/mruby-metaprog/test/metaprog.rb
+assert('Kernel#__send__', '15.3.1.3.4') do
+ # test with block
+ l = __send__(:lambda) do
+ true
+ end
+
+ assert_true l.call
+ assert_equal Proc, l.class
+ # test with argument
+ assert_true __send__(:respond_to?, :nil?)
+ # test without argument and without block
+ assert_equal String, __send__(:to_s).class
+end
+
+assert('Kernel#send', '15.3.1.3.44') do
+ # test with block
+ l = send(:lambda) do
+ true
+ end
+
+ assert_true l.call
+ assert_equal l.class, Proc
+ # test with argument
+ assert_true send(:respond_to?, :nil?)
+ # test without argument and without block
+ assert_equal send(:to_s).class, String
+end
assert('Kernel#instance_variable_defined?', '15.3.1.3.20') do
o = Object.new

MODIFY
mrbgems/mruby-method/test/method.rb
mrbgems/mruby-method/test/method.rb
@@ -102,10 +102,7 @@ end
assert 'Method#call for regression' do
obj = BasicObject.new
- def obj.foo
- :ok
- end
- assert_equal :ok, Kernel.instance_method(:send).bind(obj).call(:foo), "https://github.com/ksss/mruby-method/issues/4"
+ assert_equal String, Kernel.instance_method(:inspect).bind(obj).call().class, "https://github.com/ksss/mruby-method/issues/4"
end
assert 'Method#call with undefined method' do

MODIFY
src/kernel.c
src/kernel.c
@@ -869,7 +869,6 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method(mrb, krn, "raise", mrb_f_raise, MRB_ARGS_ANY()); /* 15.3.1.3.40 */
mrb_define_method(mrb, krn, "remove_instance_variable", mrb_obj_remove_instance_variable,MRB_ARGS_REQ(1)); /* 15.3.1.3.41 */
mrb_define_method(mrb, krn, "respond_to?", obj_respond_to, MRB_ARGS_ANY()); /* 15.3.1.3.43 */
- mrb_define_method(mrb, krn, "send", mrb_f_send, MRB_ARGS_ANY()); /* 15.3.1.3.44 */
mrb_define_method(mrb, krn, "to_s", mrb_any_to_s, MRB_ARGS_NONE()); /* 15.3.1.3.46 */
mrb_define_method(mrb, krn, "__case_eqq", mrb_obj_ceqq, MRB_ARGS_REQ(1)); /* internal */

MODIFY
test/t/codegen.rb
test/t/codegen.rb
@@ -184,14 +184,14 @@ assert('register window of calls (#3783)') do
# NODE_UNDEF
assert_nothing_raised do
class << Object.new
- undef send
+ undef inspect
end
end
# NODE_ALIAS
assert_nothing_raised do
class << Object.new
- alias send2 send
+ alias inspect2 inspect
end
end
end

MODIFY
test/t/kernel.rb
test/t/kernel.rb
@@ -92,20 +92,6 @@ assert('Kernel#__id__', '15.3.1.3.3') do
assert_equal Fixnum, __id__.class
end
-assert('Kernel#__send__', '15.3.1.3.4') do
- # test with block
- l = __send__(:lambda) do
- true
- end
-
- assert_true l.call
- assert_equal Proc, l.class
- # test with argument
- assert_true __send__(:respond_to?, :nil?)
- # test without argument and without block
- assert_equal String, __send__(:to_s).class
-end
-
assert('Kernel#block_given?', '15.3.1.3.6') do
def bg_try(&b)
if block_given?
@@ -440,20 +426,6 @@ assert('Kernel#respond_to?', '15.3.1.3.43') do
assert_false Test4RespondTo.new.respond_to?(:test_method)
end
-assert('Kernel#send', '15.3.1.3.44') do
- # test with block
- l = send(:lambda) do
- true
- end
-
- assert_true l.call
- assert_equal l.class, Proc
- # test with argument
- assert_true send(:respond_to?, :nil?)
- # test without argument and without block
- assert_equal send(:to_s).class, String
-end
-
assert('Kernel#to_s', '15.3.1.3.46') do
assert_equal to_s.class, String
end

MODIFY
test/t/module.rb
test/t/module.rb
@@ -536,61 +536,61 @@ end
#end
# mruby has no visibility control
- assert 'Module#prepend visibility' do
- bug8005 = '[ruby-core:53106] [Bug #8005]'
- c = Class.new do
- prepend Module.new {}
- def foo() end
- protected :foo
- end
- a = c.new
- assert_true a.respond_to?(:foo), bug8005
- assert_nothing_raised(bug8005) {a.send :foo}
- end
+ # assert 'Module#prepend visibility' do
+ # bug8005 = '[ruby-core:53106] [Bug #8005]'
+ # c = Class.new do
+ # prepend Module.new {}
+ # def foo() end
+ # protected :foo
+ # end
+ # a = c.new
+ # assert_true a.respond_to?(:foo), bug8005
+ # assert_nothing_raised(bug8005) {a.send :foo}
+ # end
# mruby has no visibility control
- assert 'Module#prepend inherited visibility' do
- bug8238 = '[ruby-core:54105] [Bug #8238]'
- module Test4PrependVisibilityInherited
- class A
- def foo() A; end
- private :foo
- end
- class B < A
- public :foo
- prepend Module.new
- end
- end
- assert_equal(Test4PrependVisibilityInherited::A, Test4PrependVisibilityInherited::B.new.foo, "#{bug8238}")
- end
+ # assert 'Module#prepend inherited visibility' do
+ # bug8238 = '[ruby-core:54105] [Bug #8238]'
+ # module Test4PrependVisibilityInherited
+ # class A
+ # def foo() A; end
+ # private :foo
+ # end
+ # class B < A
+ # public :foo
+ # prepend Module.new
+ # end
+ # end
+ # assert_equal(Test4PrependVisibilityInherited::A, Test4PrependVisibilityInherited::B.new.foo, "#{bug8238}")
+ # end
- assert 'Module#prepend super in alias' do
- skip "super does not currently work in aliased methods"
- bug7842 = '[Bug #7842]'
+ # assert 'Module#prepend super in alias' do
+ # skip "super does not currently work in aliased methods"
+ # bug7842 = '[Bug #7842]'
- p = labeled_module("P") do
- def m; "P"+super; end
- end
+ # p = labeled_module("P") do
+ # def m; "P"+super; end
+ # end
- a = labeled_class("A") do
- def m; "A"; end
- end
+ # a = labeled_class("A") do
+ # def m; "A"; end
+ # end
- b = labeled_class("B", a) do
- def m; "B"+super; end
- alias m2 m
- prepend p
- alias m3 m
- end
+ # b = labeled_class("B", a) do
+ # def m; "B"+super; end
+ # alias m2 m
+ # prepend p
+ # alias m3 m
+ # end
- assert_nothing_raised do
- assert_equal("BA", b.new.m2, bug7842)
- end
+ # assert_nothing_raised do
+ # assert_equal("BA", b.new.m2, bug7842)
+ # end
- assert_nothing_raised do
- assert_equal("PBA", b.new.m3, bug7842)
- end
- end
+ # assert_nothing_raised do
+ # assert_equal("PBA", b.new.m3, bug7842)
+ # end
+ # end
assert 'Module#prepend each class' do
m = labeled_module("M")

Move `Kernel#send` to `mruby-metaprog` gem.

But `BasicObject#__send__` is still available from the core.