Skip to content

Commit 2e05d06

Browse files
committed
tests: Move anonymous type<>() field access tests into anon-access.bas
1 parent 6b5be9d commit 2e05d06

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

tests/structs/anon-access.bas

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,56 @@
22

33
namespace fbc_tests.structs.anon_access
44

5-
type UDT
5+
type PodUdt
6+
i as integer
7+
end type
8+
9+
type CtorUdt
610
as integer a, b
711
declare constructor( )
812
end type
913

10-
constructor UDT( )
14+
constructor CtorUdt( )
1115
a = 123
1216
b = 456
1317
end constructor
1418

19+
sub test cdecl( )
20+
CU_ASSERT( (type<PodUdt>( 123 )).i = 123 )
21+
CU_ASSERT( type<PodUdt>( 123 ).i = 123 )
22+
end sub
23+
1524
private sub test3538470 cdecl( )
1625
'' Regression test for bug #3538470
1726
'' This used to trigger an out-of-bounds array access in fbc
1827
dim x as integer
1928

2029
CU_ASSERT( x = 0 )
21-
x = (UDT( )).a
30+
x = (CtorUdt( )).a
2231
CU_ASSERT( x = 123 )
23-
CU_ASSERT( (UDT( )).a = 123 )
24-
CU_ASSERT( 123 = (UDT( )).a )
32+
CU_ASSERT( (CtorUdt( )).a = 123 )
33+
CU_ASSERT( 123 = (CtorUdt( )).a )
2534

26-
x = (UDT( )).b
35+
x = (CtorUdt( )).b
2736
CU_ASSERT( x = 456 )
28-
CU_ASSERT( (UDT( )).b = 456 )
29-
CU_ASSERT( 456 = (UDT( )).b )
37+
CU_ASSERT( (CtorUdt( )).b = 456 )
38+
CU_ASSERT( 456 = (CtorUdt( )).b )
3039

31-
x = (type<UDT>( )).a
40+
x = (type<CtorUdt>( )).a
3241
CU_ASSERT( x = 123 )
33-
CU_ASSERT( (type<UDT>( )).a = 123 )
34-
CU_ASSERT( 123 = (type<UDT>( )).a )
42+
CU_ASSERT( (type<CtorUdt>( )).a = 123 )
43+
CU_ASSERT( 123 = (type<CtorUdt>( )).a )
3544

36-
x = (type<UDT>( )).b
45+
x = (type<CtorUdt>( )).b
3746
CU_ASSERT( x = 456 )
38-
CU_ASSERT( (type<UDT>( )).b = 456 )
39-
CU_ASSERT( 456 = (type<UDT>( )).b )
47+
CU_ASSERT( (type<CtorUdt>( )).b = 456 )
48+
CU_ASSERT( 456 = (type<CtorUdt>( )).b )
4049
end sub
4150

4251
private sub ctor( ) constructor
4352
fbcu.add_suite( "tests/structs/anon-access" )
4453
fbcu.add_test( "#3538470", @test3538470 )
54+
fbcu.add_test( "test", @test )
4555
end sub
4656

4757
end namespace

tests/structs/anon-assign.bas

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ namespace ctorcallDespiteConstBits
8181
end sub
8282
end namespace
8383

84-
namespace memberAccess
85-
type UDT
86-
i as integer
87-
end type
88-
89-
sub test cdecl( )
90-
CU_ASSERT( (type<UDT>( 123 )).i = 123 )
91-
CU_ASSERT( type<UDT>( 123 ).i = 123 )
92-
end sub
93-
end namespace
94-
9584
namespace anonCtorCallInit
9685
type A
9786
i as integer
@@ -127,7 +116,6 @@ private sub ctor( ) constructor
127116
fbcu.add_test("test_3", @test_3)
128117
fbcu.add_test("test_4", @test_4)
129118
fbcu.add_test( "ctorcall + CONST bits", @ctorcallDespiteConstBits.test )
130-
fbcu.add_test( "member access", @memberAccess.test )
131119
fbcu.add_test( "type() initializer for UDTs with ctor", @anonCtorCallInit.test )
132120
end sub
133121

0 commit comments

Comments
 (0)