/
macro_no_parentheses.bas
92 lines (60 loc) · 1.56 KB
/
macro_no_parentheses.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# include "fbcunit.bi"
SUITE( fbc_tests.pp.macro_no_parentheses )
TEST( initializer )
# macro m1 ? ( foo, bar )
foo + bar
# endmacro
var hello = m1 "hello", "!"
var world = m1 "world", "!"
END_TEST
TEST( nested1 )
#macro of ? ( __T__ )
##__T__
#endmacro
#define conc( __A__, __B__ ) __A__##__B__
#define tostr( __S__ ) __fb_quote__( __S__ )
#macro template ? ( __N__, __T__ )
tostr( conc( __N__, __T__ ) )
#endmacro
type Foo
as integer bar
end type
dim s as string
s = template( Foo, of( bar ) )
CU_ASSERT_EQUAL( s, "Foobar" )
s = template( Foo, of bar )
CU_ASSERT_EQUAL( s, "Foobar" )
s = template Foo, of bar
CU_ASSERT_EQUAL( s, "Foobar" )
END_TEST
TEST( nested2 )
#define tostr( __S__ ) __fb_quote__( __S__ )
#macro foo ? ( a, b )
__fb_quote__( a b )
#endmacro
#macro bar ? ( a, b, c )
__fb_quote__( a b c )
#endmacro
#macro baz ? ( a, b, c )
__fb_quote__( a b c )
#endmacro
dim s as string
dim c as string = "$""1 2 3"" $""4 5 6"""
s = foo( bar( 1, 2, 3 ), baz( 4, 5, 6 ) )
CU_ASSERT_EQUAL( s, c )
s = foo( bar 1, 2, 3, baz( 4, 5, 6 ) )
CU_ASSERT_EQUAL( s, c )
s = foo( bar( 1, 2, 3 ), baz 4, 5, 6 )
CU_ASSERT_EQUAL( s, c )
s = foo( bar 1, 2, 3, baz 4, 5, 6 )
CU_ASSERT_EQUAL( s, c )
s = foo bar( 1, 2, 3 ), baz( 4, 5, 6 )
CU_ASSERT_EQUAL( s, c )
s = foo bar 1, 2, 3, baz( 4, 5, 6 )
CU_ASSERT_EQUAL( s, c )
s = foo bar( 1, 2, 3 ), baz 4, 5, 6
CU_ASSERT_EQUAL( s, c )
s = foo bar 1, 2, 3, baz 4, 5, 6
CU_ASSERT_EQUAL( s, c )
END_TEST
END_SUITE