ruby-changes:73795
From: Benoit <ko1@a...>
Date: Thu, 29 Sep 2022 22:48:52 +0900 (JST)
Subject: [ruby-changes:73795] c6319026ca (master): Extend tests for a zsuper method of which the method it resolved to has been removed
https://git.ruby-lang.org/ruby.git/commit/?id=c6319026ca From c6319026caa6c8f0f569f80011e8502349a04b14 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Thu, 29 Sep 2022 13:56:03 +0200 Subject: Extend tests for a zsuper method of which the method it resolved to has been removed --- test/ruby/test_method.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 85733094cd..0b838f5e40 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -1241,11 +1241,52 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L1241 a.remove_method(:foo) + assert_equal "#<UnboundMethod: B(A)#foo(arg=...) #{__FILE__}:#{line}>", unbound.inspect assert_equal [[:opt, :arg]], unbound.parameters + + obj = b.new + assert_equal 1, unbound.bind_call(obj) + + assert_include b.instance_methods(false), :foo + assert_equal "#<UnboundMethod: B#foo(*)>", b.instance_method(:foo).inspect + end + + def test_zsuper_method_removed_higher_method + a0 = EnvUtil.labeled_class('A0') do + def foo(arg1 = nil, arg2 = nil) + 0 + end + end + line0 = __LINE__ - 4 + a0_foo = a0.instance_method(:foo) + + a = EnvUtil.labeled_class('A', a0) do + private + def foo(arg = nil) + 1 + end + end + line = __LINE__ - 4 + + b = EnvUtil.labeled_class('B', a) do + public :foo + end + + unbound = b.instance_method(:foo) + + assert_equal a0_foo, unbound.super_method + + a.remove_method(:foo) + assert_equal "#<UnboundMethod: B(A)#foo(arg=...) #{__FILE__}:#{line}>", unbound.inspect + assert_equal [[:opt, :arg]], unbound.parameters + assert_equal a0_foo, unbound.super_method obj = b.new assert_equal 1, unbound.bind_call(obj) + + assert_include b.instance_methods(false), :foo + assert_equal "#<UnboundMethod: B(A0)#foo(arg1=..., arg2=...) #{__FILE__}:#{line0}>", b.instance_method(:foo).inspect end def test_zsuper_method_redefined_bind_call -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/