mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
proc.c: main.define_method
* proc.c (top_define_method): new method, main.define_method. [ruby-core:45715] [Feature #6609] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
603fcafdc3
commit
499b5a9197
4 changed files with 52 additions and 1 deletions
|
@ -407,6 +407,24 @@ class TestEval < Test::Unit::TestCase
|
|||
assert_equal("ok", x)
|
||||
end
|
||||
|
||||
def test_define_method_toplevel
|
||||
feature6609 = '[ruby-core:45715]'
|
||||
main = eval("self", TOPLEVEL_BINDING)
|
||||
assert_nothing_raised(NoMethodError, feature6609) do
|
||||
main.instance_eval do
|
||||
define_method("feature6609_block") {feature6609}
|
||||
end
|
||||
end
|
||||
assert_equal(feature6609, feature6609_block)
|
||||
|
||||
assert_nothing_raised(NoMethodError, feature6609) do
|
||||
main.instance_eval do
|
||||
define_method("feature6609_method", Object.instance_method(:feature6609_block))
|
||||
end
|
||||
end
|
||||
assert_equal(feature6609, feature6609_method)
|
||||
end
|
||||
|
||||
def test_eval_using_integer_as_binding
|
||||
assert_raise(TypeError) { eval("", 1) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue