-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathwith-type.bas
78 lines (63 loc) · 1.36 KB
/
with-type.bas
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "fbcunit.bi"
SUITE( fbc_tests.compound.with_type )
dim shared dtor_count as integer = 0
type T0
dim as integer i
dim as integer j
end type
TEST( udt0 )
with type<T0>(11, 12)
CU_ASSERT_EQUAL( .i, 11 )
CU_ASSERT_EQUAL( .j, 12 )
end with
END_TEST
'' ---------
type T1
dim as integer i
dim as integer j
declare destructor()
end type
destructor T1()
CU_ASSERT_EQUAL( this.i, 21 )
CU_ASSERT_EQUAL( this.j, 22 )
this.i = 0
this.j = 0
dtor_count += 1
end destructor
TEST( udt1 )
dtor_count = 0
with type<T1>(21, 22)
CU_ASSERT_EQUAL( .i, 21 )
CU_ASSERT_EQUAL( .j, 22 )
CU_ASSERT_EQUAL( dtor_count, 0 )
end with
CU_ASSERT_EQUAL( dtor_count, 1 )
END_TEST
'' ---------
type T2
dim as integer i
dim as integer j
declare constructor(byval i0 as integer, byval j0 as integer)
declare destructor()
end type
constructor T2(byval i0 as integer, byval j0 as integer)
this.i = i0
this.j = j0
end constructor
destructor T2()
CU_ASSERT_EQUAL( this.i, 31 )
CU_ASSERT_EQUAL( this.j, 32 )
this.i = 0
this.j = 0
dtor_count += 1
end destructor
TEST( udt2 )
dtor_count = 0
with type<T2>(31, 32)
CU_ASSERT_EQUAL( .i, 31 )
CU_ASSERT_EQUAL( .j, 32 )
CU_ASSERT_EQUAL( dtor_count, 0 )
end with
CU_ASSERT_EQUAL( dtor_count, 1 )
END_TEST
END_SUITE