From 1eee78b8769f7f01cead3b0782e1ee4ed84e281b Mon Sep 17 00:00:00 2001 From: matz Date: Sun, 4 Nov 2007 20:36:20 +0000 Subject: [PATCH] * eval.c (rb_f_send): allow send/__send__ to call methods of all visibility again. we no longer provide __send, __send!. * eval.c (rb_invoke_method): new method to honor private visibility. if it's invoked in a function call style, it calls private methods as well (previous 1.9 send behavior). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++ bootstraptest/test_eval.rb | 4 +-- bootstraptest/test_method.rb | 10 +++---- compile.c | 4 +-- eval.c | 48 ++++++++++++++++------------------ eval_method.ci | 6 ++--- id.c | 2 -- insnhelper.ci | 6 +---- lib/date.rb | 18 ++++++------- lib/delegate.rb | 8 +++--- lib/drb/drb.rb | 2 +- lib/matrix.rb | 2 +- lib/monitor.rb | 12 ++++----- lib/net/imap.rb | 10 +++---- lib/net/smtp.rb | 2 +- test/pathname/test_pathname.rb | 12 +++------ test/rss/test_content.rb | 2 +- test/rss/test_dublincore.rb | 4 +-- test/rss/test_syndication.rb | 2 +- test/rss/test_taxonomy.rb | 2 +- test/rss/test_trackback.rb | 2 +- test/ruby/test_alias.rb | 2 +- test/ruby/test_assignment.rb | 2 +- test/ruby/test_eval.rb | 4 +-- test/ruby/test_primitive.rb | 2 +- test/socket/test_socket.rb | 8 +++--- test/socket/test_udp.rb | 4 +-- yarvtest/test_eval.rb | 4 +-- 28 files changed, 92 insertions(+), 101 deletions(-) diff --git a/ChangeLog b/ChangeLog index 848b8c10f2..ee3d42d287 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,15 @@ Mon Nov 5 01:02:56 2007 Minero Aoki User-Agent to fix 500 error on some corrupted HTTP servers. [ruby-core:13135] +Mon Nov 5 00:32:32 2007 Yukihiro Matsumoto + + * eval.c (rb_f_send): allow send/__send__ to call methods of all + visibility again. we no longer provide __send, __send!. + + * eval.c (rb_invoke_method): new method to honor private + visibility. if it's invoked in a function call style, it calls + private methods as well (previous 1.9 send behavior). + Mon Nov 5 00:24:24 2007 NAKAMURA Usaku * win32/Makefile.sub: vendor_ruby support. diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb index 5de4f4ef8c..ed3deba989 100644 --- a/bootstraptest/test_eval.rb +++ b/bootstraptest/test_eval.rb @@ -89,12 +89,12 @@ assert_equal %q{1}, %q{ eval('a') } assert_equal %q{ok}, %q{ - __send! :eval, %{ + __send__ :eval, %{ :ok } } assert_equal %q{ok}, %q{ - 1.__send! :instance_eval, %{ + 1.__send__ :instance_eval, %{ :ok } } diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index 54ba5f8442..76901f6f6e 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -314,9 +314,9 @@ assert_equal '1', %q( class C; def m(x,a=7) a end end; assert_equal '[1, 2]', %q( class C; def m(*a) a end end; C.new.send(:m,1,2).inspect ) assert_equal '1', %q( class C; def m() 7 end; private :m end - begin C.new.send(:m); rescue NoMethodError; 1 end ) + begin C.new.invoke_method(:m); rescue NoMethodError; 1 end ) assert_equal '1', %q( class C; def m() 1 end; private :m end - C.new.send!(:m) ) + C.new.send(:m) ) # with block assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]', @@ -867,8 +867,6 @@ assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{ end end - alias send! send unless defined? send! - c1 = c2 = nil lambda{ @@ -899,8 +897,8 @@ assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{ test{o2.mm} test{o1.send :m} test{o2.send :mm} - test{o1.send! :m} - test{o2.send! :mm} + test{o1.invoke_method :m} + test{o2.invoke_method :mm} test{o1.method(:m).call} test{o2.method(:mm).call} $ans diff --git a/compile.c b/compile.c index a420589398..523c753dce 100644 --- a/compile.c +++ b/compile.c @@ -1483,11 +1483,11 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj) } if (mid == idSend || mid == id__send || - mid == idSendBang || mid == id__send_bang || + mid == idSendBang || mid == id__send__ ) { OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BIT); } - if (mid == idSendBang || mid == id__send_bang) { + if (mid == idSendBang) { OPERAND_AT(iobj, 3) |= INT2FIX(VM_CALL_SEND_BANG_BIT); } } diff --git a/eval.c b/eval.c index cddf518adf..c17ac16b08 100644 --- a/eval.c +++ b/eval.c @@ -25,7 +25,7 @@ static VALUE rb_frame_self(void); static ID removed, singleton_removed, undefined, singleton_undefined; static ID init, eqq, each, aref, aset, match, missing; static ID added, singleton_added; -static ID object_id, __send, __send_bang, respond_to; +static ID object_id, __send__, respond_to; VALUE rb_eLocalJumpError; VALUE rb_eSysStackError; @@ -1471,7 +1471,7 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope) /* * call-seq: * obj.send(symbol [, args...]) => obj - * obj.__send__(symbol [, args...]) => obj + * obj.__send__(symbol [, args...]) => obj * * Invokes the method identified by _symbol_, passing it any * arguments specified. You can use __send__ if the name @@ -1488,6 +1488,24 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope) VALUE rb_f_send(int argc, VALUE *argv, VALUE recv) +{ + return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE); +} + + +/* + * call-seq: + * obj.invoke_method(symbol [, args...]) => obj + * + * Invokes the method identified by _symbol_, passing it any + * 1arguments specified. Unlike send, invoke_method calls public + * methods only, unless it's invoked in a function call style. + * + * 1.invoke_method(:puts, "hello") # causes NoMethodError + */ + +VALUE +rb_invoke_method(int argc, VALUE *argv, VALUE recv) { int scope = NOEX_PUBLIC; rb_thread_t *th = GET_THREAD(); @@ -1500,25 +1518,6 @@ rb_f_send(int argc, VALUE *argv, VALUE recv) return send_internal(argc, argv, recv, scope); } -/* - * call-seq: - * obj.send!(symbol [, args...]) => obj - * obj.__send!(symbol [, args...]) => obj - * - * Invokes the method identified by _symbol_, passing it any - * arguments specified. Unlike send, which calls public methods only - * when it is invoked in function call style, send! always aware of - * private methods. - * - * 1.send!(:puts, "hello") # prints "foo" - */ - -VALUE -rb_f_send_bang(int argc, VALUE *argv, VALUE recv) -{ - return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE); -} - VALUE rb_funcall(VALUE recv, ID mid, int n, ...) { @@ -2718,8 +2717,7 @@ Init_eval(void) singleton_undefined = rb_intern("singleton_method_undefined"); object_id = rb_intern("object_id"); - __send = rb_intern("__send"); - __send_bang = rb_intern("__send!"); + __send__ = rb_intern("__send__"); rb_define_virtual_variable("$@", errat_getter, errat_setter); rb_define_virtual_variable("$!", errinfo_getter, 0); @@ -2748,9 +2746,7 @@ Init_eval(void) rb_define_method(rb_cBasicObject, "send", rb_f_send, -1); rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1); - rb_define_method(rb_cBasicObject, "__send", rb_f_send, -1); - rb_define_method(rb_cBasicObject, "send!", rb_f_send_bang, -1); - rb_define_method(rb_cBasicObject, "__send!", rb_f_send_bang, -1); + rb_define_method(rb_mKernel, "invoke_method", rb_invoke_method, -1); rb_define_method(rb_mKernel, "instance_eval", rb_obj_instance_eval, -1); rb_define_method(rb_mKernel, "instance_exec", rb_obj_instance_exec, -1); diff --git a/eval_method.ci b/eval_method.ci index 6d86e52c50..ff4d3cb0a5 100644 --- a/eval_method.ci +++ b/eval_method.ci @@ -158,7 +158,7 @@ rb_add_method(VALUE klass, ID mid, NODE * node, int noex) } } - if (mid == object_id || mid == __send || mid == __send_bang) { + if (mid == object_id || mid == __send__) { if (node && nd_type(node) == RUBY_VM_METHOD_NODE) { rb_warn("redefining `%s' may cause serious problem", rb_id2name(mid)); @@ -302,7 +302,7 @@ remove_method(VALUE klass, ID mid) } if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); - if (mid == object_id || mid == __send || mid == __send_bang || mid == init) { + if (mid == object_id || mid == __send__ || mid == init) { rb_warn("removing `%s' may cause serious problem", rb_id2name(mid)); } if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) { @@ -466,7 +466,7 @@ rb_undef(VALUE klass, ID id) rb_id2name(id)); } rb_frozen_class_p(klass); - if (id == object_id || id == __send || id == __send_bang || id == init) { + if (id == object_id || id == __send__ || id == init) { rb_warn("undefining `%s' may cause serious problem", rb_id2name(id)); } body = search_method(klass, id, &origin); diff --git a/id.c b/id.c index 28d7d54f2f..034c0fdd0a 100644 --- a/id.c +++ b/id.c @@ -62,7 +62,5 @@ Init_id(void) idSend = rb_intern("send"); idSendBang = rb_intern("send!"); - id__send = rb_intern("__send"); - id__send_bang = rb_intern("__send!"); id__send__ = rb_intern("__send__"); } diff --git a/insnhelper.ci b/insnhelper.ci index d067903ad8..7e5067b92d 100644 --- a/insnhelper.ci +++ b/insnhelper.ci @@ -588,10 +588,9 @@ vm_send_optimize(rb_control_frame_t *reg_cfp, { if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) { NODE *node = (*mn)->nd_body; - extern VALUE rb_f_send_bang(int argc, VALUE *argv, VALUE recv); extern VALUE rb_f_send(int argc, VALUE *argv, VALUE recv); - if (node->nd_cfnc == rb_f_send_bang || node->nd_cfnc == rb_f_send) { + if (node->nd_cfnc == rb_f_send) { int i = *num - 1; VALUE sym = TOPN(i); *id = SYMBOL_P(sym) ? SYM2ID(sym) : rb_to_id(sym); @@ -604,9 +603,6 @@ vm_send_optimize(rb_control_frame_t *reg_cfp, *mn = rb_method_node(klass, *id); *num -= 1; DEC_SP(1); - } - - if (node->nd_cfnc == rb_f_send_bang) { *flag |= VM_CALL_FCALL_BIT; } } diff --git a/lib/date.rb b/lib/date.rb index 1d949e59d1..b480e39cfc 100644 --- a/lib/date.rb +++ b/lib/date.rb @@ -877,14 +877,14 @@ class Date when :civil g[1].each do |e| break if elem[e] - elem[e] = d.__send!(e) + elem[e] = d.__send__(e) end elem[:mon] ||= 1 elem[:mday] ||= 1 when :commercial g[1].each do |e| break if elem[e] - elem[e] = d.__send!(e) + elem[e] = d.__send__(e) end elem[:cweek] ||= 1 elem[:cwday] ||= 1 @@ -893,14 +893,14 @@ class Date when :wnum0 g[1].each do |e| break if elem[e] - elem[e] = d.__send!(e) + elem[e] = d.__send__(e) end elem[:wnum0] ||= 0 elem[:wday] ||= 0 when :wnum1 g[1].each do |e| break if elem[e] - elem[e] = d.__send!(e) + elem[e] = d.__send__(e) end elem[:wnum1] ||= 0 elem[:wday] ||= 0 @@ -1727,16 +1727,16 @@ class Time def to_time() getlocal end def to_date - jd = Date.__send!(:civil_to_jd, year, mon, mday, Date::ITALY) - Date.new!(Date.__send!(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY) + jd = Date.__send__(:civil_to_jd, year, mon, mday, Date::ITALY) + Date.new!(Date.__send__(:jd_to_ajd, jd, 0, 0), 0, Date::ITALY) end def to_datetime - jd = DateTime.__send!(:civil_to_jd, year, mon, mday, DateTime::ITALY) - fr = DateTime.__send!(:time_to_day_fraction, hour, min, [sec, 59].min) + + jd = DateTime.__send__(:civil_to_jd, year, mon, mday, DateTime::ITALY) + fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec, 59].min) + usec.to_r/86400_000_000 of = utc_offset.to_r/86400 - DateTime.new!(DateTime.__send!(:jd_to_ajd, jd, fr, of), + DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of), of, DateTime::ITALY) end diff --git a/lib/delegate.rb b/lib/delegate.rb index 9084a7f191..809faa32c6 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -115,7 +115,7 @@ # implementation, see SimpleDelegator. # class Delegator - preserved = [:__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :send!] + preserved = [:__id__, :object_id, :__send__, :invoke_method, :respond_to?, :send] instance_methods.each do |m| next if preserved.include?(m) undef_method m @@ -137,7 +137,7 @@ class Delegator unless target.respond_to?(m) super(m, *args, &block) else - target.__send(m, *args, &block) + target.__send__(m, *args, &block) end rescue Exception $@.delete_if{|s| /^#{__FILE__}:\d+:in `method_missing'$/ =~ s} #` @@ -262,7 +262,7 @@ def DelegateClass(superclass) klass = Class.new methods = superclass.public_instance_methods(true) methods -= [ - :__id__, :object_id, :__send__, :__send, :__send!, :respond_to?, :send, :send!, + :__id__, :object_id, :__send__, :invoke_method, :respond_to?, :send, :==, :equal?, :initialize, :method_missing, :__getobj__, :__setobj__, :clone, :dup, :marshal_dump, :marshal_load, ] @@ -281,7 +281,7 @@ def DelegateClass(superclass) klass.module_eval <<-EOS, __FILE__, __LINE__+1 def #{method}(*args, &block) begin - @delegate_dc_obj.__send(:#{method}, *args, &block) + @delegate_dc_obj.__send__(:#{method}, *args, &block) rescue raise $!, $@[2..-1] end diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index e7686801f7..a3e0ed927f 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -1553,7 +1553,7 @@ module DRb end ary.collect(&@obj)[0] else - @obj.send!(@msg_id, *@argv) + @obj.send(@msg_id, *@argv) end end diff --git a/lib/matrix.rb b/lib/matrix.rb index 8f2d472b88..bbb1144e10 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -246,7 +246,7 @@ class Matrix # use to general users. # def initialize(init_method, *argv) - self.send!(init_method, *argv) + self.send(init_method, *argv) end def init_rows(rows, copy) diff --git a/lib/monitor.rb b/lib/monitor.rb index 1b61f54dba..31234819b8 100644 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -91,13 +91,13 @@ module MonitorMixin if timeout raise NotImplementedError, "timeout is not implemented yet" end - @monitor.send!(:mon_check_owner) - count = @monitor.send!(:mon_exit_for_cond) + @monitor.send(:mon_check_owner) + count = @monitor.send(:mon_exit_for_cond) begin @cond.wait(@monitor.instance_variable_get("@mon_mutex")) return true ensure - @monitor.send!(:mon_enter_for_cond, count) + @monitor.send(:mon_enter_for_cond, count) end end @@ -114,12 +114,12 @@ module MonitorMixin end def signal - @monitor.send!(:mon_check_owner) + @monitor.send(:mon_check_owner) @cond.signal end def broadcast - @monitor.send!(:mon_check_owner) + @monitor.send(:mon_check_owner) @cond.broadcast end @@ -137,7 +137,7 @@ module MonitorMixin def self.extend_object(obj) super(obj) - obj.send!(:mon_initialize) + obj.send(:mon_initialize) end # diff --git a/lib/net/imap.rb b/lib/net/imap.rb index f84229f131..087306e8d3 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -1229,7 +1229,7 @@ module Net class RawData # :nodoc: def send_data(imap) - imap.send!(:put_string, @data) + imap.send(:put_string, @data) end private @@ -1241,7 +1241,7 @@ module Net class Atom # :nodoc: def send_data(imap) - imap.send!(:put_string, @data) + imap.send(:put_string, @data) end private @@ -1253,7 +1253,7 @@ module Net class QuotedString # :nodoc: def send_data(imap) - imap.send!(:send_quoted_string, @data) + imap.send(:send_quoted_string, @data) end private @@ -1265,7 +1265,7 @@ module Net class Literal # :nodoc: def send_data(imap) - imap.send!(:send_literal, @data) + imap.send(:send_literal, @data) end private @@ -1277,7 +1277,7 @@ module Net class MessageSet # :nodoc: def send_data(imap) - imap.send!(:put_string, format_internal(@data)) + imap.send(:put_string, format_internal(@data)) end private diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 84790450bc..8f81ae8450 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -722,7 +722,7 @@ module Net def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE) check_auth_method authtype check_auth_args user, secret - send! auth_method(authtype), user, secret + send auth_method(authtype), user, secret end def auth_plain(user, secret) diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 4c9c9e1e52..f3a39a015a 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -9,12 +9,6 @@ require 'enumerator' class TestPathname < Test::Unit::TestCase - if RUBY_VERSION < "1.9" - FUNCALL = :__send__ - else - FUNCALL = :send! - end - def self.define_assertion(name, &block) @defassert_num ||= {} @defassert_num[name] ||= 0 @@ -123,7 +117,7 @@ class TestPathname < Test::Unit::TestCase # has_trailing_separator?(path) -> bool def has_trailing_separator?(path) - Pathname.allocate.send(FUNCALL, :has_trailing_separator?, path) + Pathname.allocate.__send__(:has_trailing_separator?, path) end defassert(:has_trailing_separator?, false, "/") @@ -132,11 +126,11 @@ class TestPathname < Test::Unit::TestCase defassert(:has_trailing_separator?, true, "a/") def add_trailing_separator(path) - Pathname.allocate.send(FUNCALL, :add_trailing_separator, path) + Pathname.allocate.__send__(:add_trailing_separator, path) end def del_trailing_separator(path) - Pathname.allocate.send(FUNCALL, :del_trailing_separator, path) + Pathname.allocate.send(__send__, :del_trailing_separator, path) end defassert(:del_trailing_separator, "/", "/") diff --git a/test/rss/test_content.rb b/test/rss/test_content.rb index 45f834de01..02db59186b 100644 --- a/test/rss/test_content.rb +++ b/test/rss/test_content.rb @@ -85,7 +85,7 @@ EOR excepted = make_element("#{@prefix}:#{name}", {}, value) meth = "#{RSS::CONTENT_PREFIX}_#{name}_element" [@rss10, @rss20].each do |rss| - assert_equal(excepted, rss.items.last.__send!(meth)) + assert_equal(excepted, rss.items.last.__send__(meth)) end end diff --git a/test/rss/test_dublincore.rb b/test/rss/test_dublincore.rb index 0e049e7910..22b81483f4 100644 --- a/test/rss/test_dublincore.rb +++ b/test/rss/test_dublincore.rb @@ -245,7 +245,7 @@ EOR excepted = "<#{DC_PREFIX}:#{name}>#{value}" parents.each do |parent_readers| parent = chain_reader(feed, parent_readers) - assert_equal(excepted, parent.__send!("dc_#{name}_elements")) + assert_equal(excepted, parent.__send__("dc_#{name}_elements")) end plural_suffix = dc_plural_suffix(name, check_backward_compatibility) @@ -257,7 +257,7 @@ EOR klass_name = "DublinCore#{Utils.to_class_name(name.to_s)}" klass = DublinCoreModel.const_get(klass_name) elems << klass.new(parent.__send__("dc_#{name}")) - assert_equal(excepted, parent.__send!("dc_#{name}_elements")) + assert_equal(excepted, parent.__send__("dc_#{name}_elements")) end end diff --git a/test/rss/test_syndication.rb b/test/rss/test_syndication.rb index 6aaaa43382..abd75e905e 100644 --- a/test/rss/test_syndication.rb +++ b/test/rss/test_syndication.rb @@ -107,7 +107,7 @@ EOR excepted = "<#{@prefix}:#{name}>#{value}" @parents.each do |parent| assert_equal(excepted, - @rss.__send__(parent).__send!("sy_#{name}_element")) + @rss.__send__(parent).__send__("sy_#{name}_element")) end end diff --git a/test/rss/test_taxonomy.rb b/test/rss/test_taxonomy.rb index 59cb2f0585..5109f3d892 100644 --- a/test/rss/test_taxonomy.rb +++ b/test/rss/test_taxonomy.rb @@ -140,7 +140,7 @@ EOR def test_to_s @topics_parents.each do |parent| meth = "taxo_topics_element" - assert_equal(@topics_node, @rss.__send__(parent).__send!(meth)) + assert_equal(@topics_node, @rss.__send__(parent).__send__(meth)) end @topic_nodes.each_with_index do |node, i| diff --git a/test/rss/test_trackback.rb b/test/rss/test_trackback.rb index db4f291317..26812d9010 100644 --- a/test/rss/test_trackback.rb +++ b/test/rss/test_trackback.rb @@ -114,7 +114,7 @@ EOR @parents.each do |parent| meth = "#{RSS::TRACKBACK_PREFIX}_#{name}_element" meth << "s" if name == :about - assert_equal(excepted, @rss.__send__(parent).__send!(meth)) + assert_equal(excepted, @rss.__send__(parent).__send__(meth)) end end diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index 4076de051b..d72fe702af 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -56,7 +56,7 @@ class TestAlias < Test::Unit::TestCase d = lambda { $SAFE = 4 dclass = Class.new(C) - dclass.send!(:alias_method, :mm, :m) + dclass.send(:alias_method, :mm, :m) dclass.new }.call assert_raise(SecurityError) { d.mm } diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb index b355e444cf..df0ae0713c 100644 --- a/test/ruby/test_assignment.rb +++ b/test/ruby/test_assignment.rb @@ -652,7 +652,7 @@ class TestAssignmentGen < Test::Unit::TestCase assign = assign.to_s code1 = "#{assign}; [#{vars.join(",")}]" assign.gsub!(/\bv\d+\b/, "o.a") - code2 = "o=[];class << o; self end.send!(:define_method,:a=){|v|self << v};#{assign};o" + code2 = "o=[];class << o; self end.send(:define_method,:a=){|v|self << v};#{assign};o" begin vals1 = eval(code1) rescue Exception diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 22cc4456d3..281548b096 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -124,7 +124,7 @@ class TestEval < Test::Unit::TestCase obj.class.class_variable_set :@@cvar, 13 # Use same value with env. See also test_instance_variable_cvar. obj.class.const_set :Const, 15 unless obj.class.const_defined?(:Const) - send! mid, obj + send mid, obj end end @@ -364,7 +364,7 @@ class TestEval < Test::Unit::TestCase assert_nothing_raised { def temporally_method_for_test_eval_and_define_method(&block) lambda { - class << Object.new; self end.send!(:define_method, :zzz, &block) + class << Object.new; self end.send(:define_method, :zzz, &block) } end v = eval("temporally_method_for_test_eval_and_define_method {}") diff --git a/test/ruby/test_primitive.rb b/test/ruby/test_primitive.rb index 68c53b0bd7..8ffbe549d6 100644 --- a/test/ruby/test_primitive.rb +++ b/test/ruby/test_primitive.rb @@ -50,7 +50,7 @@ class TestRubyPrimitive < Test::Unit::TestCase assert_equal 3, A::B::C::Const assert_equal 3, A::B::C.new.const assert_equal 1, ::TestRubyPrimitive::A::Const - A::B::C.send!(:remove_const, :Const) + A::B::C.send(:remove_const, :Const) assert_equal 2, A::B::C.new.const assert_raise(TypeError) { C::CONST diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index dc61ede9d7..2eba8a1cb0 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -19,7 +19,7 @@ class TestBasicSocket < Test::Unit::TestCase n = s.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR) assert_equal([0].pack("i"), n) val = Object.new - class << val; self end.send!(:define_method, :to_int) { + class << val; self end.send(:define_method, :to_int) { s.close Socket::SO_TYPE } @@ -34,7 +34,7 @@ class TestBasicSocket < Test::Unit::TestCase linger = [0, 0].pack("ii") val = Object.new - class << val; self end.send!(:define_method, :to_str) { + class << val; self end.send(:define_method, :to_str) { s.close linger } @@ -47,7 +47,7 @@ class TestBasicSocket < Test::Unit::TestCase end val = Object.new - class << val; self end.send!(:define_method, :to_int) { + class << val; self end.send(:define_method, :to_int) { s.close Socket::SO_LINGER } @@ -61,7 +61,7 @@ class TestBasicSocket < Test::Unit::TestCase def test_listen s = nil log = Object.new - class << log; self end.send!(:define_method, :to_int) { + class << log; self end.send(:define_method, :to_int) { s.close 2 } diff --git a/test/socket/test_udp.rb b/test/socket/test_udp.rb index 654b506573..07fd17a2cb 100644 --- a/test/socket/test_udp.rb +++ b/test/socket/test_udp.rb @@ -9,7 +9,7 @@ class TestUDPSocket < Test::Unit::TestCase def test_connect # [ruby-dev:25045] s = UDPSocket.new host = Object.new - class << host; self end.send!(:define_method, :to_str) { + class << host; self end.send(:define_method, :to_str) { s.close "127.0.0.1" } @@ -21,7 +21,7 @@ class TestUDPSocket < Test::Unit::TestCase def test_bind # [ruby-dev:25057] s = UDPSocket.new host = Object.new - class << host; self end.send!(:define_method, :to_str) { + class << host; self end.send(:define_method, :to_str) { s.close "127.0.0.1" } diff --git a/yarvtest/test_eval.rb b/yarvtest/test_eval.rb index 8a82c4cff4..0432caa3f1 100644 --- a/yarvtest/test_eval.rb +++ b/yarvtest/test_eval.rb @@ -16,12 +16,12 @@ class TestEval < YarvTestBase def test_eval_with_send ae %q{ - __send! :eval, %{ + __send__ :eval, %{ :ok } } ae %q{ - 1.__send! :instance_eval, %{ + 1.__send__ :instance_eval, %{ :ok } }