diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-01-18 00:09:26 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-01-18 00:09:26 +0900 |
| commit | c8536d977d477c87b61398d376339760ef1c77b1 (patch) | |
| tree | 322dd098b7a4704d20d0ed0afb26267fa5cbab07 /test | |
| parent | c83069860a4b5f3aa2c64621e52f7877fe2a453a (diff) | |
| parent | a68b568911f5dbf762d26ba21e4171bc7a2473e5 (diff) | |
| download | mruby-c8536d977d477c87b61398d376339760ef1c77b1.tar.gz mruby-c8536d977d477c87b61398d376339760ef1c77b1.zip | |
Merge pull request #3362 from ksss/proc
Proc shouldn't have `initialize` method
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/proc.rb | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/test/t/proc.rb b/test/t/proc.rb index 29530e8dd..ef4566e66 100644 --- a/test/t/proc.rb +++ b/test/t/proc.rb @@ -46,17 +46,6 @@ assert('Proc#arity', '15.2.17.4.2') do assert_equal(-1, g) end -assert('Proc#arity with unitialized Proc') do - begin - Proc.alias_method(:original_initialize, :initialize) - Proc.remove_method(:initialize) - assert_equal 0, Proc.new{|a, b, c| 1}.arity - ensure - Proc.alias_method(:initialize, :original_initialize) - Proc.remove_method(:original_initialize) - end -end - assert('Proc#call', '15.2.17.4.3') do a = 0 b = Proc.new { a += 1 } @@ -147,6 +136,18 @@ assert('Proc#return_does_not_break_self') do assert_equal c, c.block.call end +assert('call Proc#initialize if defined') do + a = [] + c = Class.new(Proc) do + define_method(:initialize) do + a << :ok + end + end + + assert_kind_of c, c.new{} + assert_equal [:ok], a +end + assert('&obj call to_proc if defined') do pr = Proc.new{} def mock(&b) @@ -163,19 +164,3 @@ assert('&obj call to_proc if defined') do assert_raise(TypeError){ mock(&(Object.new)) } end - -assert('initialize_copy works when initialize is removed') do - begin - Proc.alias_method(:old_initialize, :initialize) - Proc.remove_method(:initialize) - - a = Proc.new {} - b = Proc.new {} - assert_nothing_raised do - a.initialize_copy(b) - end - ensure - Proc.alias_method(:initialize, :old_initialize) - Proc.remove_method(:old_initialize) - end -end |
