mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_eval.rb (test_define_method_block): new test
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
166f8d6d0b
commit
8676f8baf2
1 changed files with 13 additions and 0 deletions
|
@ -358,6 +358,19 @@ class TestEval < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_define_method_block
|
||||||
|
cc = Class.new do
|
||||||
|
define_method(:foo) {|&block|
|
||||||
|
block.call if block
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
c = cc.new
|
||||||
|
x = "ng"
|
||||||
|
c.foo() {x = "ok"}
|
||||||
|
assert_equal("ok", x)
|
||||||
|
end
|
||||||
|
|
||||||
def test_eval_using_integer_as_binding
|
def test_eval_using_integer_as_binding
|
||||||
assert_raise(TypeError) { eval("", 1) }
|
assert_raise(TypeError) { eval("", 1) }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue