summaryrefslogtreecommitdiff
path: root/t/inherit.t
blob: 58f7e22e59888e03b8f3bd9cf62c1664f0b4db21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash 
 
. t/testlib.sh
 
class A; do
 
    function thing() {
        echo "<$self> A/thing ($*)"
    }
 
done
 
class B; do
    extends A
 
    function other() {
        echo "<$self> B/other ($*)"
    }
 
done
 
class C; do
    extends B
 
    function thing() {
        echo "<$self> C/thing ($*)"
 
        $self next/method "$@"
    }
 
done
 
A new-into objA
B new-into objB
C new-into objC
 
[[ -n "$objA" ]]; should-succeed simple instantiation
[[ -n "$objB" ]]; should-succeed instantiation with inheritance
 
is "$($objA thing 1 2 3)" "<*A*> A/thing (1 2 3)" direct call
is "$($objB other a b c)" "<*B*> B/other (a b c)" direct call
is "$($objB thing 4 5 6)" "<*B*> A/thing (4 5 6)" inherited call
is "$($objC thing 7 8 9)" $'<*C*> C/thing (7 8 9)\n<*C*> A/thing (7 8 9)' next/method
 
 
done-testing