diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-17 12:25:47 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-17 12:25:47 +0000 |
commit | d8e600c60c1f97f6b5f9b301c52dade25bab5dbe (patch) | |
tree | 9f8d1c255a53e591b22b132f3dbf0f30ffd9dbeb /bootstraptest/test_method.rb | |
parent | 0dfdf0dd9f0ed7bdebbc006dd76bb7fdd22b1207 (diff) | |
download | ruby-d8e600c60c1f97f6b5f9b301c52dade25bab5dbe.tar.gz ruby-d8e600c60c1f97f6b5f9b301c52dade25bab5dbe.tar.xz ruby-d8e600c60c1f97f6b5f9b301c52dade25bab5dbe.zip |
* eval.c (rb_call), eval_method.ci (rb_add_method, rb_alias),
insnhelper.ci (vm_call_method): fix to save safelevel for
method node.
* include/ruby/node.h: ditto.
* bootstraptest/test_method.rb: add a test for above.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest/test_method.rb')
-rw-r--r-- | bootstraptest/test_method.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb index 7f20bf5a9..28fee41d1 100644 --- a/bootstraptest/test_method.rb +++ b/bootstraptest/test_method.rb @@ -860,5 +860,49 @@ class C0; def m *args; [:C0_m, args]; end; end class C1 < C0; def m a, o=:o; super; end; end ; C1.new.m 1, 2} +assert_equal %q{[:ok, :ok, :ok, :ok, :ok, :ok, :ng, :ng]}, %q{ + $ans = [] + class Foo + def m + end + end + + alias funcall send unless defined? funcall + + c1 = c2 = nil + + lambda{ + $SAFE = 4 + c1 = Class.new{ + def m + end + } + c2 = Class.new(Foo){ + alias mm m + } + }.call + + def test + begin + yield + rescue SecurityError + $ans << :ok + else + $ans << :ng + end + end + o1 = c1.new + o2 = c2.new + + test{o1.m} + test{o2.mm} + test{o1.send :m} + test{o2.send :mm} + test{o1.funcall :m} + test{o2.funcall :mm} + test{o1.method(:m).call} + test{o2.method(:mm).call} + $ans +} |