mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 14:18:42 +01:00
Get basic superclass method calls working.
This commit is contained in:
22
test/super/call_other_method.wren
Normal file
22
test/super/call_other_method.wren
Normal file
@ -0,0 +1,22 @@
|
||||
class Base {
|
||||
foo {
|
||||
io.write("Base.foo")
|
||||
}
|
||||
}
|
||||
|
||||
class Derived is Base {
|
||||
bar {
|
||||
io.write("Derived.bar")
|
||||
super.foo
|
||||
}
|
||||
}
|
||||
|
||||
Derived.new.bar
|
||||
// expect: Derived.bar
|
||||
// expect: Base.foo
|
||||
|
||||
// TODO(bob): Super constructor calls.
|
||||
// TODO(bob): Super operator calls.
|
||||
// TODO(bob): Calling super outside of a class.
|
||||
// TODO(bob): Super calls inside nested functions in methods.
|
||||
// TODO(bob): Super where there is no inherited method.
|
||||
16
test/super/call_same_method.wren
Normal file
16
test/super/call_same_method.wren
Normal file
@ -0,0 +1,16 @@
|
||||
class Base {
|
||||
foo {
|
||||
io.write("Base.foo")
|
||||
}
|
||||
}
|
||||
|
||||
class Derived is Base {
|
||||
foo {
|
||||
io.write("Derived.foo")
|
||||
super.foo
|
||||
}
|
||||
}
|
||||
|
||||
Derived.new.foo
|
||||
// expect: Derived.foo
|
||||
// expect: Base.foo
|
||||
18
test/super/indirectly_inherited.wren
Normal file
18
test/super/indirectly_inherited.wren
Normal file
@ -0,0 +1,18 @@
|
||||
class A {
|
||||
foo {
|
||||
io.write("A.foo")
|
||||
}
|
||||
}
|
||||
|
||||
class B is A {}
|
||||
|
||||
class C is B {
|
||||
foo {
|
||||
io.write("C.foo")
|
||||
super.foo
|
||||
}
|
||||
}
|
||||
|
||||
C.new.foo
|
||||
// expect: C.foo
|
||||
// expect: A.foo
|
||||
Reference in New Issue
Block a user