-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathfor_UDT_counter3.bas
70 lines (56 loc) · 1.36 KB
/
for_UDT_counter3.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
# include "fbcunit.bi"
SUITE( fbc_tests.compound.for_UDT_counter3 )
static shared as integer dtor_cnt = 0
type foo
declare constructor( v as integer )
declare destructor( )
declare operator for( )
declare operator for( byref stp as foo )
declare operator step( )
declare operator step( byref stp as foo )
declare operator next( byref end_cond as foo ) as integer
declare operator next( byref end_cond as foo, byref stp as foo ) as integer
private:
value as integer
is_up as integer
end type
constructor foo( v as integer )
value = v
end constructor
operator foo.for( )
is_up = -1
end operator
operator foo.for( byref stp as foo )
is_up = (stp.value >= 0)
end operator
destructor foo( )
dtor_cnt += 1
end destructor
operator foo.step( )
value += 1
end operator
operator foo.step( byref stp as foo )
value += stp.value
end operator
operator foo.next( byref end_cond as foo ) as integer
operator = value <= end_cond.value
end operator
operator foo.next( byref end_cond as foo, byref stp as foo ) as integer
if( is_up ) then
operator = value <= end_cond.value
else
operator = value >= end_cond.value
end if
end operator
TEST( test_temp )
do
do
'' this should create 3 temporaries
for i as foo = 1 to 2 step 1
exit do, do
next
loop
loop
CU_ASSERT_EQUAL( dtor_cnt, 3 )
END_TEST
END_SUITE