aboutsummaryrefslogtreecommitdiffstats
path: root/test/cedet/tests/testsppreplace.c
diff options
context:
space:
mode:
authorChong Yidong2009-09-28 23:23:31 +0000
committerChong Yidong2009-09-28 23:23:31 +0000
commit74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a (patch)
treed895d7e93cf93022f48bd6d173f616f1bb4b99fc /test/cedet/tests/testsppreplace.c
parentb9de0a4665563f847bc7c94f8c89180bf2a9f6bd (diff)
downloademacs-74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a.tar.gz
emacs-74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a.zip
Add CEDET tests.
Diffstat (limited to 'test/cedet/tests/testsppreplace.c')
-rw-r--r--test/cedet/tests/testsppreplace.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/test/cedet/tests/testsppreplace.c b/test/cedet/tests/testsppreplace.c
new file mode 100644
index 00000000000..390e0953fcb
--- /dev/null
+++ b/test/cedet/tests/testsppreplace.c
@@ -0,0 +1,135 @@
1/* Test CPP/SPP Replacement
2 */
3
4/* TEST: The EMU keyword doesn't screw up the function defn. */
5#define EMU
6#define EMU2 /*comment*/
7char EMU parse_around_emu EMU2 (EMU)
8{
9}
10
11/* TEST: A simple word can be replaced in a definition. */
12#define SUBFLOAT /* Some Float */ float
13SUBFLOAT returnanfloat()
14{
15}
16
17/* TEST: Punctuation an be replaced in a definition. */
18#define COLON :
19int foo COLON COLON bar ()
20{
21}
22
23/* TEST: Multiple lexical characters in a definition */
24#define SUPER mysuper::
25int SUPER baz ()
26{
27}
28
29/* TEST: Macro replacement. */
30#define INT_FCN(name) int name (int in)
31
32INT_FCN(increment) {
33 return in+1;
34}
35
36/* TEST: Macro replacement with complex args */
37#define P_(proto) ()
38
39int myFcn1 P_((a,b));
40
41#define P__(proto) proto
42
43int myFcn2 P__((int a, int b));
44int myFcn3 (int a, int b);
45
46/* TEST: Multiple args to a macro. */
47#define MULTI_ARGS(name, field1, field2, field3) struct name { int field1; int field2; int field3; }
48
49MULTI_ARGS(ma_struct, moose, penguin, emu);
50
51/* TEST: Macro w/ args, but no body. */
52#define NO_BODY(name)
53
54NO_BODY(Moose);
55
56/* TEST: Not a macro with args, but close. */
57#define NOT_WITH_ARGS (moose)
58
59int not_with_args_fcn NOT_WITH_ARGS
60{
61}
62
63/* TEST: macro w/ continuation. */
64#define WITH_CONT \
65 continuation_symbol
66
67int WITH_CONT () { };
68
69/* TEST: macros in a macro - tail processing */
70#define tail_with_args_and_long_name(a) (int a)
71#define int_arg tail_with_args_and_long_name
72
73int tail int_arg(q) {}
74
75/* TEST: macros used improperly. */
76#define tail_fail tail_with_args_and_long_name(q)
77
78int tail_fcn tail_fail(q);
79
80/* TEST: feature of CPP from LSD <lsdsgster@...> */
81#define __gthrw_(name) __gthrw_ ## name
82
83int __gthrw_(foo) (int arg1) { }
84
85/* TEST: macros using macros */
86#define macro_foo foo
87#define mf_declare int macro_foo
88
89mf_declare;
90
91/* TEST: macros with args using macros */
92#define Amacro(A) (int A)
93#define mf_Amacro(B) int B Amacro(B)
94
95mf_Amacro(noodle);
96
97/* TEST: Double macro using the argument stack. */
98#define MACRO0(name) int that_ ## name(int i);
99#define MACRO1(name) int this_ ## name(int i);
100#define MACRO2(name) MACRO0(name) MACRO1(name)
101
102MACRO2(foo)
103
104/* TEST: The G++ namespace macro hack. Not really part of SPP. */
105_GLIBCXX_BEGIN_NAMESPACE(baz)
106
107 int bazfnc(int b) { }
108
109_GLIBCXX_END_NAMESPACE;
110
111_GLIBCXX_BEGIN_NESTED_NAMESPACE(foo,bar)
112
113 int foo_bar_func(int a) { }
114
115_GLIBCXX_END_NESTED_NAMESPACE;
116
117
118/* TEST: The VC++ macro hack. */
119_STD_BEGIN
120
121 int inside_std_namespace(int a) { }
122
123_STD_END
124
125/* TEST: Recursion prevention. CPP doesn't allow even 1 level of recursion. */
126#define STARTMACRO MACROA
127#define MACROA MACROB
128#define MACROB MACROA
129
130int STARTMACRO () {
131
132}
133
134
135/* END */