Commit ea805982

ea80598202f6Merged

Dmitry Bochkarev <[email protected]> · 6 months ago · 2 files · +2 added

Description

test: multi-level inherited dispatch via poly recv

Details

Commit
ea80598202f6
Parent
627925a9a309

test/poly_dispatch_multilevel_inheritance.rbaddedView file

1+# Three-level inheritance (Base -> Child -> GrandChild) plus a
2+# Sibling. All inherit #greet from Base without overriding it.
3+# Calling via a poly-typed parameter must dispatch correctly for
4+# every level in the chain.
5+
6+class Base
7+ def greet
8+ "hello"
9+ end
10+end
11+
12+class Child < Base
13+end
14+
15+class GrandChild < Child
16+end
17+
18+class Sibling < Base
19+end
20+
21+def call_greet(e)
22+ e.greet
23+end
24+
25+puts call_greet(Base.new)
26+puts call_greet(Child.new)
27+puts call_greet(GrandChild.new)
28+puts call_greet(Sibling.new)