aboutsummaryrefslogtreecommitdiff
path: root/tests/i/class-delete/program.cps
blob: 492c032f43f783e006128c7504fa3bd1842734cc (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

CLASS Leaf
    Value : INTEGER
    PROCEDURE DELETE()
        OUTPUT "leaf:", Value
    ENDPROCEDURE
ENDCLASS
CLASS Pair
    Left : Leaf
    Right : Leaf
    PROCEDURE NEW()
        Left.Value <- 1
        Right.Value <- 2
    ENDPROCEDURE
    PROCEDURE DELETE()
        OUTPUT "pair"
    ENDPROCEDURE
ENDCLASS
DECLARE Obj : Pair
Obj <- NEW Pair()
Obj.DELETE()
CALL Obj.DELETE()
DELETE Obj
TRY
    DELETE Obj
CATCH
    OUTPUT "double caught"
ENDTRY
DECLARE Stack : Pair
TRY
    DELETE Stack
CATCH
    OUTPUT "stack caught"
ENDTRY
DECLARE Items : ARRAY[1:2] OF Pair
Items[2].Right.DELETE()