diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-21 08:45:57 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-21 08:45:57 +0000 |
commit | 93639b65bdea42bf8e7360a81376ce319e7e38b5 (patch) | |
tree | 53fac06efc9b08a19a446fddc9f77b394dde17ce /test/ruby/test_method.rb | |
parent | 60a9b0440002f9a004bdb7025aeba6849b60dd6c (diff) | |
download | ruby-93639b65bdea42bf8e7360a81376ce319e7e38b5.tar.gz |
* proc.c: fix issues caused by binding created from Method#to_proc.
[Bug #11163]
* vm.c (vm_cref_new_toplevel): export as rb_vm_cref_new_toplevel().
* test/ruby/test_method.rb: add some assersions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_method.rb')
-rw-r--r-- | test/ruby/test_method.rb | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 960c4270d1..d1cde99ab4 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -887,17 +887,25 @@ class TestMethod < Test::Unit::TestCase end end + class C + D = "Const_D" + def foo + a = b = c = 12345 + end + end + def test_to_proc_binding bug11012 = '[ruby-core:68673] [Bug #11012]' - class << (obj = Object.new) - src = 1000.times.map {|i|"v#{i} = nil"}.join("\n") - eval("def foo()\n""#{src}\n""end") - end - b = obj.method(:foo).to_proc.binding - b.local_variables.each_with_index {|n, i| - b.local_variable_set(n, i) - } - assert_equal([998, 999], %w[v998 v999].map {|n| b.local_variable_get(n)}, bug11012) + b = C.new.method(:foo).to_proc.binding + assert_equal([], b.local_variables) + assert_equal("Const_D", b.eval("D")) # Check CREF + + assert_raise(NameError){ b.local_variable_get(:foo) } + assert_equal(123, b.local_variable_set(:foo, 123)) + assert_equal(123, b.local_variable_get(:foo)) + assert_equal(456, b.local_variable_set(:bar, 456)) + assert_equal(123, b.local_variable_get(:foo)) + assert_equal(456, b.local_variable_get(:bar)) end end |