Skip to content

Commit 0f1ff15

Browse files
committed
fbc-tests: add tests/structs/implicit-cast.bas for implicit cast on UDT cast operator
1 parent 9542d00 commit 0f1ff15

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/structs/implicit-cast.bas

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "fbcunit.bi"
2+
3+
SUITE( fbc_tests.structs.implicit_cast )
4+
5+
TEST_GROUP( cast_string )
6+
7+
function p overload( byref z as const wstring ) as string
8+
return "wstring"
9+
end function
10+
11+
function p( byref s as const string ) as string
12+
return "string"
13+
end function
14+
15+
type T
16+
__ as integer
17+
declare operator cast() as string
18+
end type
19+
operator T.cast() as string
20+
return "123"
21+
end operator
22+
23+
TEST( default )
24+
dim x as T
25+
CU_ASSERT( left( x, 1 ) = "1" )
26+
CU_ASSERT( right( x, 1 ) = "3" )
27+
CU_ASSERT( p( x ) = "string" )
28+
END_TEST
29+
30+
END_TEST_GROUP
31+
32+
END_SUITE

0 commit comments

Comments
 (0)