Add a test for Binding#local_variable* with numbered parameters and it
This commit is contained in:
parent
993fd96ce6
commit
3a0d00ddfb
Notes:
git
2025-02-18 07:23:41 +00:00
@ -1649,6 +1649,71 @@ class TestProc < Test::Unit::TestCase
|
||||
assert_equal(20, b.eval("b"))
|
||||
end
|
||||
|
||||
def test_numparam_is_not_local_variables
|
||||
"foo".tap do
|
||||
_9
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:_9) }
|
||||
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
|
||||
"bar".tap do
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:_9) }
|
||||
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
|
||||
end
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:_9) }
|
||||
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
|
||||
end
|
||||
|
||||
"foo".tap do
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:_9) }
|
||||
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
|
||||
"bar".tap do
|
||||
_9
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:_9) }
|
||||
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
|
||||
end
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:_9) }
|
||||
assert_raise(NameError) { binding.local_variable_set(:_9, 1) }
|
||||
end
|
||||
end
|
||||
|
||||
def test_it_is_not_local_variable
|
||||
"foo".tap do
|
||||
it
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
"bar".tap do
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
end
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
"bar".tap do
|
||||
it
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
end
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
end
|
||||
|
||||
"foo".tap do
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
"bar".tap do
|
||||
it
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
end
|
||||
assert_equal([], binding.local_variables)
|
||||
assert_raise(NameError) { binding.local_variable_get(:it) }
|
||||
end
|
||||
end
|
||||
|
||||
def test_local_variable_set_wb
|
||||
assert_ruby_status([], <<-'end;', '[Bug #13605]', timeout: 30)
|
||||
b = binding
|
||||
|
Loading…
x
Reference in New Issue
Block a user