Files
wren/test/language/inheritance/inherit_methods.wren
T

26 lines
669 B
Plaintext
Raw Normal View History

2013-11-13 11:05:03 -08:00
class Foo {
2015-09-15 07:46:09 -07:00
methodOnFoo { System.print("foo") }
method(a) { System.print("foo") }
method(a, b, c) { System.print("foo") }
override { System.print("foo") }
2013-11-13 11:05:03 -08:00
}
class Bar is Foo {
2015-09-01 08:16:04 -07:00
construct new() {}
2015-09-15 07:46:09 -07:00
methodOnBar { System.print("bar") }
method(a, b) { System.print("bar") }
method(a, b, c, d) { System.print("bar") }
override { System.print("bar") }
2013-11-13 11:05:03 -08:00
}
2015-07-10 09:18:22 -07:00
var bar = Bar.new()
2013-11-13 11:05:03 -08:00
bar.methodOnFoo // expect: foo
bar.methodOnBar // expect: bar
// Methods with different arity do not shadow each other.
bar.method(1) // expect: foo
bar.method(1, 2) // expect: bar
bar.method(1, 2, 3) // expect: foo
bar.method(1, 2, 3, 4) // expect: bar
bar.override // expect: bar