diff options
| author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-01-06 00:24:59 +0000 |
|---|---|---|
| committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-01-06 00:24:59 +0000 |
| commit | 2725f1eb4ceb3a1aba0654c58ebfbb8adef7a9f3 (patch) | |
| tree | f4252badb58ec3ab74af8c2f2a99db6ccbf4d4ab /yarvtest | |
| parent | 9c2436e55289f38dd4fc9801badb65562610b69c (diff) | |
| download | ruby-2725f1eb4ceb3a1aba0654c58ebfbb8adef7a9f3.tar.gz ruby-2725f1eb4ceb3a1aba0654c58ebfbb8adef7a9f3.tar.xz ruby-2725f1eb4ceb3a1aba0654c58ebfbb8adef7a9f3.zip | |
* insns.def : support direct method dispatch with "send" or "funcall".
This means that "obj.send :m" skips "BasicObject#send" invocation
(method frame creation, etc) and "obj.m" invokes directly.
If you make backtrace, there are no enties of "send" method.
* compile.c (iseq_specialized_instruction) : fix to support above
* eval.c : ditto (remove "static" from rb_f_send and rb_f_funcall
* yarvcore.c : ditto (add a external IDs for compiler)
* yarvcore.h : ditto (add a VM_CALL_SEND_BIT macro)
* yarvtest/test_method.rb : add tests for above changes
* eval.c : remove unused "Kernel#send" declaration
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'yarvtest')
| -rw-r--r-- | yarvtest/test_method.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/yarvtest/test_method.rb b/yarvtest/test_method.rb index c2ef4c99d..60e7a9dd4 100644 --- a/yarvtest/test_method.rb +++ b/yarvtest/test_method.rb @@ -535,5 +535,64 @@ class TestMethod < YarvTestBase C.new.m
}
end
+
+ def test_send
+ ae %q{
+ $r = []
+ class C
+ def m *args
+ $r << "C#m #{args.inspect} #{block_given?}"
+ end
+ end
+
+ obj = C.new
+ obj.send :m
+ obj.send :m, :x
+ obj.send :m, :x, :y
+ obj.send(:m){}
+ obj.send(:m, :x){}
+ $r
+ }
+ end
+
+ def test_send_with_private
+ ae %q{
+ begin
+ def m
+ end
+ self.send :m
+ rescue NoMethodError
+ :ok
+ else
+ :ng
+ end
+ }
+ ae %q{
+ begin
+ def m
+ end
+ send :m
+ rescue NoMethodError
+ :ng
+ else
+ :ok
+ end
+ }
+ end
+
+ def test_funcall
+ ae %q{
+ $r = []
+ def m *args
+ $r << "m() #{args.inspect} #{block_given?}"
+ end
+
+ funcall :m
+ funcall :m, :x
+ funcall :m, :x, :y
+ funcall(:m){}
+ funcall(:m, :x){}
+ }
+ end
end
|
