diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-13 09:13:33 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-05-13 09:13:33 +0900 |
| commit | b4657182da44febeccd5f22af636bceda776122f (patch) | |
| tree | 14553befe49eb23a0118014da900b6fc347f2922 /test/t | |
| parent | bcbf078ebd4c3346982d0dc8e125da12b61a04bc (diff) | |
| download | mruby-b4657182da44febeccd5f22af636bceda776122f.tar.gz mruby-b4657182da44febeccd5f22af636bceda776122f.zip | |
convert &arg using to_proc; fix #2242
Diffstat (limited to 'test/t')
| -rw-r--r-- | test/t/proc.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/t/proc.rb b/test/t/proc.rb index 33c3a0ef2..e871e637e 100644 --- a/test/t/proc.rb +++ b/test/t/proc.rb @@ -131,3 +131,20 @@ assert('Proc#return_does_not_break_self') do assert_equal nil, c.return_nil assert_equal c, c.block.call end + +assert('&obj call to_proc if defined') do + pr = Proc.new{} + def mock(&b) + b + end + assert_equal pr.object_id, mock(&pr).object_id + assert_equal pr, mock(&pr) + + obj = Object.new + def obj.to_proc + Proc.new{ :from_to_proc } + end + assert_equal :from_to_proc, mock(&obj).call + + assert_raise(TypeError){ mock(&(Object.new)) } +end |
