aboutsummaryrefslogtreecommitdiff
path: root/tests/i/string-aggregate-assignment/program.cps
blob: 9659437e7a18fc8445a74f0346ab04854abd9fb2 (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

GLOBAL
    DECLARE Destroyed : INTEGER
    DECLARE Copies : INTEGER
ENDGLOBAL
CLASS Box
    Text : STRING
    OVERLOAD PROCEDURE NEW()
    ENDPROCEDURE
    OVERLOAD PROCEDURE NEW(BYREF Other : Box)
        Text <- Other.Text
        Copies <- Copies + 1
    ENDPROCEDURE
    PROCEDURE DELETE()
        Destroyed <- Destroyed + 1
    ENDPROCEDURE
ENDCLASS
PROCEDURE Check()
    DECLARE A : Box
    DECLARE B : Box
    A.Text <- "left"
    B.Text <- "right"
    B <- A
    B <- B
    B.Text <- "changed"
    OUTPUT A.Text, ":", B.Text, ":", Destroyed, ":", Copies
ENDPROCEDURE
CALL Check()
OUTPUT Destroyed, ":", Copies