summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-21 08:45:57 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-21 08:45:57 +0000
commit928d89c77b81b7ef560c0f40b0119dfcd31f3605 (patch)
tree53fac06efc9b08a19a446fddc9f77b394dde17ce /test
parente398e64ad73fbdb3d7fc75b5f88a9b9e50f47b52 (diff)
* 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')
-rw-r--r--test/ruby/test_method.rb26
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