aboutsummaryrefslogtreecommitdiffstats
path: root/test/cedet/tests
diff options
context:
space:
mode:
authorChong Yidong2009-09-20 04:00:13 +0000
committerChong Yidong2009-09-20 04:00:13 +0000
commit17af2991b5bd71ed2d3d69fd4467e1fc8a31d8d1 (patch)
tree8ff33ff92ead70e1a3aeead0d1334b4aedac027b /test/cedet/tests
parent00999a2ef0648870573dcb3a3866c6401db8bc28 (diff)
downloademacs-17af2991b5bd71ed2d3d69fd4467e1fc8a31d8d1.tar.gz
emacs-17af2991b5bd71ed2d3d69fd4467e1fc8a31d8d1.zip
Add Semantic unit tests.
Diffstat (limited to 'test/cedet/tests')
-rw-r--r--test/cedet/tests/scopetest.cpp47
-rw-r--r--test/cedet/tests/scopetest.java25
-rw-r--r--test/cedet/tests/templates.cpp129
-rw-r--r--test/cedet/tests/test.c222
-rw-r--r--test/cedet/tests/test.cpp593
-rw-r--r--test/cedet/tests/test.el141
-rw-r--r--test/cedet/tests/test.make60
-rw-r--r--test/cedet/tests/test.py579
-rw-r--r--test/cedet/tests/testdoublens.cpp148
-rw-r--r--test/cedet/tests/testdoublens.hpp51
-rw-r--r--test/cedet/tests/testfriends.cpp37
-rw-r--r--test/cedet/tests/testjavacomp.java69
-rw-r--r--test/cedet/tests/testnsp.cpp28
-rw-r--r--test/cedet/tests/testpolymorph.cpp131
-rw-r--r--test/cedet/tests/testspp.c84
-rw-r--r--test/cedet/tests/testsppcomplete.c29
-rw-r--r--test/cedet/tests/testsppreplace.c135
-rw-r--r--test/cedet/tests/testsppreplaced.c97
-rw-r--r--test/cedet/tests/teststruct.cpp66
-rw-r--r--test/cedet/tests/testsubclass.cpp231
-rw-r--r--test/cedet/tests/testsubclass.hh175
-rw-r--r--test/cedet/tests/testtemplates.cpp90
-rw-r--r--test/cedet/tests/testtypedefs.cpp74
-rw-r--r--test/cedet/tests/testusing.cpp132
-rw-r--r--test/cedet/tests/testusing.hh125
-rw-r--r--test/cedet/tests/testvarnames.c71
26 files changed, 3569 insertions, 0 deletions
diff --git a/test/cedet/tests/scopetest.cpp b/test/cedet/tests/scopetest.cpp
new file mode 100644
index 00000000000..e84dd0dde06
--- /dev/null
+++ b/test/cedet/tests/scopetest.cpp
@@ -0,0 +1,47 @@
1/* Test scoping rules for c++ in the analyzer. */
2
3namespace {
4
5 class aclass2; // Forward reference.
6
7 class aclass1 {
8 private:
9 int attrp1;
10 int amethodp1(int argp1);
11 aclass2 areference;
12 protected:
13 int attrpr1;
14 public:
15 int attr1;
16 int amethod1(int arg1);
17 };
18}
19
20namespace {
21 class aclass2 : public aclass1
22 {
23 private:
24 int attrp2;
25 int amethodp2(int argp1);
26 public:
27 aclass2(int aninitvalue);
28 ~aclass2();
29 int attr2;
30 int amethod2(int arg2);
31 };
32}
33
34aclass2::aclass2(init aninitvalue)
35{
36 /* This is a comment that talks about aclass1 */
37 aclass1;
38}
39
40int aclass2::amethod2(int arg2)
41{
42 int alocalvar;
43 float q;
44
45 ac;
46}
47
diff --git a/test/cedet/tests/scopetest.java b/test/cedet/tests/scopetest.java
new file mode 100644
index 00000000000..01825896b47
--- /dev/null
+++ b/test/cedet/tests/scopetest.java
@@ -0,0 +1,25 @@
1class Foo {
2
3 public void a1() {}
4
5 class Bar {
6
7 public int a2() {}
8
9 public void b() {
10 a // -1-
11 }
12
13 class Baz {
14
15 public int a3() {}
16
17 public Baz(int a4) {
18 a // -2-
19 }
20
21 }
22
23 }
24
25} \ No newline at end of file
diff --git a/test/cedet/tests/templates.cpp b/test/cedet/tests/templates.cpp
new file mode 100644
index 00000000000..5ddee820e24
--- /dev/null
+++ b/test/cedet/tests/templates.cpp
@@ -0,0 +1,129 @@
1// C++ examples and requests from Klaus Berndl
2
3// template in a unnamed namespace
4namespace
5{
6 template<typename Target, typename Source>
7 Target lexical_cast(Source arg)
8 {
9 std::stringstream interpreter;
10 Target result;
11
12 if(!(interpreter << arg) || !(interpreter >> result) ||
13 !(interpreter >> std::ws).eof())
14 throw bad_lexical_cast();
15
16 return result;
17 }
18}
19
20
21template <class T, FOO> class Vector
22{
23private:
24 static T* v;
25 int sz;
26
27public:
28 T& elem(int i) {return v[i];}
29 virtual ~Vector ();
30
31protected:
32 Vector ();
33};
34
35template <> class Vector <void*>
36{
37private:
38 void** v;
39 int sz;
40
41public:
42 Vector ();
43 virtual int func1(int i);
44 virtual int func2(int i) = 0;
45 static virtual int func3(int i) = 0;
46 void*& elem(int i) {return v[i];}
47 //...
48};
49
50// template contains namespace
51typedef vector<CzkUtilities::Action*> ActionList;
52
53// declaration of some template-types
54map<XXX, Test::YYY>** map_var;
55
56map_with_size<XXX, Test::YYY, size> map_size_var;
57typedef map_with_size<XXX, Test::YYY, size> SizedMap;
58
59map_with_10_size<XXX, Test::YYY, 10>* pMap_size10_var;
60typedef map_with_10_size<XXX, Test::YYY, 10> Size10Map;
61
62// a function which such a template-argument
63void* test_function(map<ClassX, Test::ClassY, 10>* pMap);
64
65
66template <class T> class Vector <T*> : private Vector <void*>
67{
68public:
69 typedef Vector <void*> Base;
70
71 Vector () : Base() {}
72
73 T*& elem(int i) {return static_cast<T*&>(Base::elem(i));}
74 //...
75};
76
77// outside method implementation of a template-class
78template<class T> T& Vector<T*>::elem(int i)
79{
80 return C;
81}
82
83// same but qualified with a namespace Testnamespace
84template<class T> T& Testnamespace::Vector<T*>::elem(int i)
85{
86 return C;
87}
88
89// function templates with keyword typename
90template<typename Target, typename Source>
91Target lexical_cast(Source arg)
92{
93 std::stringstream interpreter;
94 Target result;
95
96 if(!(interpreter << arg) || !(interpreter >> result) ||
97 !(interpreter >> std::ws).eof())
98 throw bad_lexical_cast();
99
100 return result;
101}
102
103template<class T>
104static
105typename T::_ptr_type
106getService(const std::string& pServiceName, const int pRetries=20)
107{
108 return T::_narrow(getServiceObject(pServiceName, pRetries));
109}
110
111// function template declaration
112template<class T> void sort(vector<T>&);
113// complex function template definition
114template<class T, class S, const NamespaceY::ClassX<TestClass, &s> volatile ***&i>
115map<ClassY, ClassX, 10>
116sort(const vector<T>& v)
117{
118 return;
119}
120
121// variable declarations of template-types
122foo<TClass, Testnamespace::XClass, i> *bar1;
123foo<TClass, Testnamespace::XClass, **&i> *bar2;
124foo<TClass, Testnamespace::XClass, *Namespace::ClassX::i> bar3;
125foo<0> bar0;
126
127class SomeName;
128class OtherName;
129
diff --git a/test/cedet/tests/test.c b/test/cedet/tests/test.c
new file mode 100644
index 00000000000..e81d79a869d
--- /dev/null
+++ b/test/cedet/tests/test.c
@@ -0,0 +1,222 @@
1/* Test file for C language.
2 * Attempt to include as many aspects of the C language as possible.
3 *
4 * $Id: test.c,v 1.12 2008/05/17 20:16:03 zappo Exp $
5 *
6 */
7/* types of include files */
8#include "includeme1.h"
9#include <includeme2.h>
10#include <subdir/includeme3.h>
11#include <includeme.notanhfile>
12#include <stdlib.h>
13#include <cmath>
14
15#if 0
16int dont_show_function()
17{
18}
19#endif
20
21/* Global types */
22struct mystruct1 {
23 int slot11;
24 char slot12;
25 float slot13;
26};
27
28struct mystruct2 {
29 int slot21;
30 char slot22;
31 float slot23;
32} var_of_type_mystruct2;
33
34struct {
35 int slot31;
36 char slot32;
37 float slot33;
38} var_of_anonymous_struct;
39
40typedef struct mystruct1 typedef_of_mystruct1;
41typedef struct mystruct1 *typedef_of_pointer_mystruct1;
42typedef struct { int slot_a; } typedef_of_anonymous_struct;
43typedef struct A {
44} B;
45
46typedef struct mystruct1 td1, td2;
47
48union myunion1 {
49 int slot41;
50 char slot42;
51 float slot43;
52};
53
54union myunion2 {
55 int slot51;
56 char slot52;
57 float slot53;
58} var_of_type_myunion2;
59
60struct {
61 int slot61;
62 char slot72;
63 float slot83;
64} var_of_anonymous_union;
65
66typedef union myunion1 typedef_of_myunion1;
67typedef union myunion1 *typedef_of_pointer_myunion1;
68typedef union { int slot_a; } typedef_of_anonymous_union;
69
70enum myenum1 { enum11 = 1, enum12 };
71enum myenum2 { enum21, enum22 = 2 } var_of_type_myenum2;
72enum { enum31, enum32 } var_of_anonymous_enum;
73
74typedef enum myenum1 typedef_of_myenum1;
75typedef enum myenum1 *typedef_of_pointer_myenum1;
76typedef enum { enum_a = 3, enum_b } typedef_of_anonymous_enum;
77
78typedef int typedef_of_int;
79
80/* Here are some simpler variable types */
81int var1;
82int varbit1:1;
83char var2;
84float var3;
85mystruct1 var3;
86struct mystruct1 var4;
87union myunion1 var5;
88enum myenum1 var6;
89
90char *varp1;
91char **varp2;
92char varv1[1];
93char varv2[1][2];
94
95char *varpa1 = "moose";
96struct mystruct2 vara2 = { 1, 'a', 0.0 };
97enum myenum1 vara3 = enum11;
98int vara4 = (int)0.0;
99int vara5 = funcall();
100
101int mvar1, mvar2, mvar3;
102char *mvarp1, *mvarp2, *mvarp3;
103char *mvarpa1 = 'a', *mvarpa2 = 'b', *mvarpa3 = 'c';
104char mvaras1[10], mvaras2[12][13], *mvaras3 = 'd';
105
106static register const unsigned int tmvar1;
107
108#define MACRO1 1
109#define MACRO2(foo) (1+foo)
110
111/* Here are some function prototypes */
112
113/* This is legal, but I decided not to support inferred integer
114 * types on functions and variables.
115 */
116fun0();
117int funp1();
118char funp2(int arg11);
119float funp3(char arg21, char arg22);
120struct mystrct1 funp4(struct mystruct2 arg31, union myunion2 arg32);
121enum myenum1 funp5(char *arg41, union myunion1 *arg42);
122
123char funpp1 __P(char argp1, struct mystruct2 argp2, char *arg4p);
124
125int fun1();
126
127/* Here is a function pointer */
128int (*funcptr)(int a, int b);
129
130/* Function Definitions */
131
132/* This is legal, but I decided not to support inferred integer
133 * types on functions and variables.
134 */
135fun0()
136{
137 int sv = 0;
138}
139
140int fun1 ()
141{
142 int sv = 1;
143}
144
145int fun1p1 (void)
146{
147 int sv = 1;
148}
149
150char fun2(int arg_11)
151{
152 char sv = 2;
153}
154
155float fun3(char arg_21, char arg_22)
156{
157 char sv = 3;
158}
159
160struct mystrct1 fun4(struct mystruct2 arg31, union myunion2 arg32)
161{
162 sv = 4;
163}
164
165enum myenum1 fun5(char *arg41, union myunion1 *arg42)
166{
167 sv = 5;
168}
169
170/* Functions with K&R syntax. */
171struct mystrct1 funk1(arg_31, arg_32)
172 struct mystruct2 arg_31;
173 union myunion2 arg32;
174{
175 sv = 4;
176}
177
178enum myenum1 *funk2(arg_41, arg_42)
179 char *arg_41;
180 union myunion1 *arg_42;
181{
182 sv = 5;
183
184 if(foo) {
185 }
186}
187
188int funk3(arg_51, arg_53)
189 int arg_51;
190 char arg_53;
191{
192 char q = 'a';
193 int sv = 6;
194 td1 ms1;
195 enum myenum1 testconst;
196
197 /* Function argument analysis */
198 funk3(ms1.slot11, arg_53 );
199 sv = 7;
200
201 /* Slot deref on assignee */
202 ms1.slot11 = s;
203
204 /* Enum/const completion */
205 testconst = e;
206
207 /* Bad var/slot and param */
208 blah.notafunction(moose);
209
210 /* Print something. */
211 printf("Moose", );
212
213 tan();
214}
215
216int funk4_fixme(arg_61, arg_62)
217 int arg_61, arg_62;
218{
219
220}
221
222/* End of C tests */
diff --git a/test/cedet/tests/test.cpp b/test/cedet/tests/test.cpp
new file mode 100644
index 00000000000..3bc1f391242
--- /dev/null
+++ b/test/cedet/tests/test.cpp
@@ -0,0 +1,593 @@
1/* Test file for C++ language.
2 * Attempt to include as many aspects of the C++ language as possible.
3 * Do not include things tested in test.c since that shares the
4 * same language.
5 *
6 * $Id: test.cpp,v 1.22 2008/05/17 20:12:55 zappo Exp $
7 *
8 */
9
10/* An include test */
11#include <stdio.h>
12
13#include <cmath>
14
15#include "c++-test.hh"
16
17#include <c++-test.hh>
18
19double var1 = 1.2;
20
21int simple1(int a) {
22
23}
24
25struct foo1 {
26 int test;
27};
28
29struct foo2 : public foo1 {
30 const int foo21(int a, int b);
31 const int foo22(int a, int b) { return 1 }
32};
33
34/* Classes */
35class class1 {
36private:
37 int var11;
38 struct foo1 var12;
39public:
40 int p_var11;
41 struct foo p_var12;
42};
43
44class i_class1 : public class1 {
45private:
46 int var11;
47 struct foo var12;
48public:
49 int p_var11;
50 struct foo p_var12;
51};
52
53class class2 {
54private:
55 int var21;
56 struct foo var22;
57public:
58 int p_var21;
59 struct foo p_var22;
60};
61
62class i_class2 : public class1, public class2 {
63private:
64 int var21;
65 struct foo var22;
66protected:
67 int pt_var21;
68public:
69 int p_var21;
70 struct foo p_var22;
71};
72
73class class3 {
74 /* A class with strange things in it */
75public:
76 class3(); /* A constructor */
77 enum embedded_foo_enum {
78 a, b, c
79 } embed1;
80 struct embedded_bar_struct {
81 int a;
82 int b;
83 } embed2;
84 class embedded_baz_class {
85 embedded_baz_class();
86 ~embedded_baz_class();
87 } embed3;
88 ~class3(); /* destructor */
89
90 /* Methods */
91 int method_for_class3(int a, char b);
92
93 int inline_method(int c) { return c; }
94
95 /* Operators */
96 class3& operator^= (const class3& something);
97
98 /* Funny declmods */
99 const class3 * const method_const_ptr_ptr(const int * const argconst) const = 0;
100};
101
102class3::class3()
103{
104 /* Constructor outside the definition. */
105}
106
107int class3::method_for_class3(int a, char b)
108{
109}
110
111int class3::method1_for_class3( int a, int &b)
112{
113 int cvariablename;
114 class3 fooy[];
115 class3 moose = new class3;
116
117 // Complktion testing line should find external members.
118 a = fooy[1].me ;
119 b = cv ;
120
121 if (fooy.emb) {
122 simple1(c);
123 }
124
125 cos(10);
126 abs(10);
127
128 return 1;
129}
130
131char class3::method2_for_class3( int a, int b) throw ( exception1 )
132{
133 return 'a';
134}
135
136void *class3::method3_for_class3( int a, int b) throw ( exception1, exception2 )
137{
138 int q = a;
139 return "Moose";
140}
141
142void *class3::method31_for_class3( int a, int b) throw ( )
143{
144 int q = a;
145 return "Moose";
146}
147
148void *class3::method4_for_class3( int a, int b) reentrant
149{
150 class3 ct;
151
152 ct.method5_for_class3(1,a);
153
154 pritf();
155}
156
157/*
158 * A method on class3.
159 */
160void *class3::method5_for_class3( int a, int b) const
161{
162}
163
164/*
165 * Namespace parsing tests
166 */
167namespace NS {
168 class class_in_namespace {
169 int equiv(const NS::class_in_namespace *) const;
170 };
171}
172
173int NS::class_in_namespace::equiv(const NS::class_in_namespace *cin) const
174{
175 return 0;
176}
177
178// Stuff Klaus found.
179// Inheritance w/out a specifying for public.
180class class4 : class1 {
181 // Pure virtual methods.
182 void virtual print () const = 0;
183
184public:
185 // The whacky constructor type
186 class4()
187 try : class1(args)
188 {
189 // constructor body
190 }
191 catch ()
192 {
193
194 }
195
196
197};
198
199class class5 : public virtual class4 {
200 // Virtual inheritance
201};
202
203class class6 : class1 {
204 // Mutable
205 mutable int i;
206};
207
208/* Namespaces */
209namespace namespace1 {
210 void ns_method1() { }
211
212 class n_class1 {
213 public:
214 void method11(int a) { }
215 };
216
217 /* This shouldn't parse due to missing semicolon. */
218 class _n_class2 : public n_class1 {
219 void n_c2_method1(int a, int b) { }
220 };
221
222 // Macros in the namespace
223#define NSMACRO 1
224
225 // Template in the namespace
226 template<class T> T nsti1(const Foo& foo);
227 template<> int nsti1<int>(const Foo& foo);
228
229}
230
231namespace namespace2 {
232
233 using namespace1::n_class1;
234
235}
236
237/* Initializers */
238void tinitializers1(): inita1(False),
239 inita2(False)
240{
241 inita1= 1;
242}
243
244/* How about Extern C type things. */
245int funny_prototype(int ,int b,float c)
246{
247
248}
249
250extern "C"
251int extern_c_1(int a, int b)
252{
253
254 funny_prototype(1,2,3.4);
255
256 printf("Moose", );
257
258 return 1;
259}
260
261extern "C" {
262
263 int extern_c_2(int a, int b)
264 {
265 return 1;
266 }
267
268}
269
270// Some operator stuff
271class Action
272{
273 // Problems!! operator() and operator[] can not be parsed with semantic
274 // 1.4.2 but with latest c.by
275 virtual void operator()(int i, char *p ) = 0;
276 virtual String& operator[]() = 0;
277 virtual void operator!() = 0;
278 virtual void operator->() = 0;
279 virtual T& operator+=();
280 virtual T& operator*();
281 virtual T& operator*=();
282};
283
284// class with namespace qualified parents
285class Multiinherit : public virtual POA::Parent,
286 public virtual POA::Parent1,
287 Parent
288{
289private:
290 int i;
291
292public:
293 Multiinherit();
294 ~Multiinherit();
295
296 // method with a list of qualified exceptions
297 void* throwtest()
298 throw(Exception0,
299 Testnamespace::Exception1,
300 Testnamespace::Excpetion2,
301 Testnamespace::testnamespace1::Exception3);
302
303};
304
305void*
306Multiinherit::throwtest()
307 throw (Exception0,
308 Testnamespace::Exception1,
309 Testnamespace::Excpetion2,
310 Testnamespace::testnamespace1::Exception3)
311{
312 return;
313}
314
315// Jens Rock <jens.rock@asamnet.de>: Nested classes or structs defined
316// outside of the containing class/struct.
317class container
318{
319 public:
320 struct contained;
321 container();
322 ~container();
323};
324
325struct container::contained
326{
327 public:
328 contained();
329 ~contained();
330};
331
332/*
333 * Ok, how about some template stuff.
334 */
335template <class CT, class container = vector<CT> >
336const CT& max (const CT& a, const CT& b)
337{
338 return a < b ? b : a;
339}
340
341// Arne Schmitz found this one
342std::vector<int> &a, &b, &c;
343
344class TemplateUsingClass
345{
346 typedef TestClassMap::iterator iterator;
347 typedef map<long, long> TestClassMap;
348
349 // typedefs with const and volatile
350 typedef const map<long, long> const_TestClassMap;
351 typedef TestClassMap<string>::iterator volatile volatile_iterator;
352
353 map<int, int> mapclassvarthingy;
354};
355
356template<class T> T ti1(const Foo& foo);
357template<> int ti1<int>(const Foo& foo);
358
359
360// -----------------------------------
361// Now some namespace and related stuff
362// -----------------------------------
363
364using CORBA::LEX::get_token;
365using Namespace1;
366
367using namespace POA::std;
368using namespace Test;
369
370
371
372namespace Parser
373{
374 namespace
375 {
376 using Lexer::get_test;
377 string str = "";
378 }
379
380 namespace XXX
381 {
382
383 class Foobar : public virtual POA::Parent,
384 public virtual POA::Parent1,
385 private POA::list<fact>,
386 private map<string>
387 {
388 ini i;
389 list <shared_ptr<item> >::const_iterator l;
390 public:
391
392 Foobar();
393 ~Foobar();
394 };
395 }
396
397
398 void test_function(int i);
399
400};
401
402// unnamed namespaces - even nested
403namespace
404{
405 namespace
406 {
407 using Lexer::get_test;
408 string str = "";
409 }
410
411 // some builtin types
412 long long ll = 0;
413 long double d = 0.0;
414 unsigned test;
415 unsigned long int **uli = 0;
416 signed si = 0;
417 signed short ss = 0;
418 short int i = 0;
419 long int li = 0;
420
421 // expressions with namespace/class-qualifyiers
422 ORB_var cGlobalOrb = ORB::_nil();
423 ORB_var1 cGlobalOrb1 = ORB::_test;
424
425 class Testclass
426 {
427 #define TEST 0
428 ini i;
429
430 public:
431
432 Testclass();
433 ~Testclass();
434 };
435
436 static void test_function(unsigned int i);
437
438};
439
440
441// outside method implementations which should be grouped to type Test
442XXX&
443Test::waiting()
444{
445 return;
446}
447
448void
449Test::print()
450{
451 return;
452}
453
454// outside method implementations with namespaces which should be grouped to
455// their complete (incl. namespace) types
456void*
457Parser::XXX::Foobar::wait(int i, const char const * const * p)
458{
459 return;
460}
461
462void*
463Namespace1::Test::wait1(int i)
464{
465 return;
466}
467
468int
469Namespace1::Test::waiting(int i)
470{
471 return;
472}
473
474// a class with some outside implementations which should all be grouped to
475// this class declaration
476class ClassWithExternals
477{
478private:
479 int i;
480
481public:
482 ClassWithExternals();
483 ~ClassWithExternals();
484 void non_nil();
485};
486
487
488// Foobar is not displayed; seems that semantic tries to add this to the class
489// Foobar but can not find/display it, because contained in the namespace above.
490void
491Foobar::non_nil()
492{
493 return;
494}
495
496// are correctly grouped to the ClassWithExternals class
497void
498ClassWithExternals::non_nil()
499{
500 String s = "lödfjg dlfgkdlfkgjdl";
501 return;
502}
503
504ClassWithExternals::ClassWithExternals()
505{
506 return;
507}
508
509void
510ClassWithExternals::~ClassWithExternals()
511{
512 return;
513}
514
515
516// -------------------------------
517// Now some macro and define stuff
518// -------------------------------
519
520#define TEST 0
521#define TEST1 "String"
522
523// The first backslash makes this macro unmatched syntax with semantic 1.4.2!
524// With flexing \+newline as nothing all is working fine!
525#define MZK_ENTER(METHOD) \
526{ \
527 CzkMethodLog lMethodLog(METHOD,"Framework");\
528}
529
530#define ZK_ASSERTM(METHOD,ASSERTION,MESSAGE) \
531 { if(!(ASSERTION))\
532 {\
533 std::ostringstream lMesgStream; \
534 lMesgStream << "Assertion failed: " \
535 << MESSAGE; \
536 CzkLogManager::doLog(CzkLogManager::FATAL,"",METHOD, \
537 "Assert",lMesgStream); \
538 assert(ASSERTION);\
539 }\
540 }
541
542// Test if not newline-backslashes are handled correctly
543string s = "My \"quoted\" string";
544
545// parsed fine as macro
546#define FOO (arg) method(arg, "foo");
547
548// With semantic 1.4.2 this parsed as macro BAR *and* function method.
549// With latest c.bnf at least one-liner macros can be parsed correctly.
550#define BAR (arg) CzkMessageLog method(arg, "bar");
551
552// some const and volatile stuff
553char * p1 = "Hello"; // 1. variable Pointer, variable Data
554const char * p2 = "Hello"; // 2. variable pointer, constant data
555char * const p3 = "Hello"; // 3. constant pointer, variable data
556const char * const p4 = "Hello"; // 4. constant pointer, constant data
557
558// Case 2 and 4 can exchange first "const" and "char"
559char const * p21 = "Hello"; // variable pointer, constant data
560char const * const p41 = "Hello"; // constant pointer, constant data
561
562char volatile a = 0; // a volatile char
563void foo(bar const &arg); // a reference to a const bar
564int foobar(bar const * const p); // a const pointer to a const bar
565int foobar(bar const volatile * const p); // a const pointer to a const bar
566int foobar3(char* p); // a const pointer to a const bar
567
568// Should not be parsed because this is invalid code
569int const & const r3 = i;
570
571boolean i = 0;
572boolean & r1 = i;
573boolean const & r2 = i;
574
575// const * sequences can be very long in C++ ;-)
576char const * const * const * const * ppp;
577
578// complex function declarationen with named pointer-arguments
579const char** foobar1(volatile char const * const **p);
580const char** foobar11(volatile Test::Namespace::Char<char*> const * const **p);
581
582// complex function declarationen with unnamed pointer-arguments
583const char* foobar2(const char***);
584const char* foobar21(const Test::Namespace::Char<char>***);
585
586// string literal parsing even with wchar_t
587char const *p = "string1";
588char const *q = "string1" "str\"ing2" "string3";
589wchar_t testc = L'a';
590
591wchar_t const *wp = L"string with a \" in it";
592wchar_t const *wq = L"string \n\t\"test" L"string2";
593wchar_t const *wr = L"string L";
diff --git a/test/cedet/tests/test.el b/test/cedet/tests/test.el
new file mode 100644
index 00000000000..2997b687677
--- /dev/null
+++ b/test/cedet/tests/test.el
@@ -0,0 +1,141 @@
1;; Test file for Emacs Lisp.
2;; Attempt to include as many aspects of Emacs Lisp as possible.
3;;
4
5;;; Require
6;;
7(require 'semantic)
8(require 'eieio "../eieio")
9
10;; tags encapsulated in eval-when-compile and eval-and-compile
11;; should be expanded out into the outer environment.
12(eval-when-compile
13 (require 'semantic-imenu)
14 )
15
16(eval-and-compile
17 (defconst const-1 nil)
18 (defun function-1 (arg)
19 nil)
20 )
21
22;;; Functions
23;;
24(defun a-defun (arg1 arg2 &optional arg3)
25 "doc a"
26 nil)
27
28(defun a-defun-interactive (arg1 arg2 &optional arg3)
29 "doc a that is a command"
30 (interactive "R")
31 nil)
32
33(defun* a-defun* (arg1 arg2 &optional arg3)
34 "doc a*"
35 nil)
36
37(defsubst a-defsubst (arg1 arg2 &optional arg3)
38 "doc a-subst"
39 nil)
40
41(defmacro a-defmacro (arg1 arg2 &optional arg3)
42 "doc a-macro"
43 nil)
44
45(define-overload a-overload (arg)
46 "doc a-overload"
47 nil)
48
49;;; Methods
50;;
51(defmethod a-method ((obj some-class) &optional arg2)
52 "Doc String for a method."
53 (call-next-method))
54
55(defgeneric a-generic (arg1 arg2)
56 "General description of a-generic.")
57
58;;; Advice
59;;
60(defadvice existing-function-to-advise (around test activate)
61 "Do something special to this fcn."
62 (ad-do-it))
63
64;;; Variables
65;;
66(defvar a-defvar (cons 1 2)
67 "Variable a")
68
69(defvar a-defvar-star (cons 1 2)
70 "*User visible var a")
71
72(defconst a-defconst 'a "var doc const")
73
74(defcustom a-defcustom nil
75 "*doc custom"
76 :group 'a-defgroup
77 :type 'boolean)
78
79(defface a-defface 'bold
80 "A face that is bold.")
81
82(defimage ezimage-page-minus
83 ((:type xpm :file "page-minus.xpm" :ascent center))
84 "Image used for open files with stuff in them.")
85
86;;; Autoloads
87;;
88(autoload (quote a-autoload) "somefile"
89 "Non-interactive autoload." nil nil)
90
91(autoload (quote a-autoload-interactive) "somefile"
92"Interactive autoload." t nil)
93
94
95(defgroup a-defgroup nil
96 "Group for `emacs-lisp' regression-test")
97
98;;; Classes
99;;
100(defclass a-class (a-parent)
101 ((slot-1)
102 (slot-2 :initarg :slot-2)
103 (slot-3 :documentation "Doc about slot3")
104 (slot-4 :type 'boolean)
105 )
106 "Doc String for class.")
107
108(defclass a-class-abstract ()
109 nil
110 "Doc string for abstract class."
111 :abstract t)
112
113;;; Structures
114;;
115(defstruct (test-struct-1 :test 'equal)
116 (slot-1 :equal 'eq)
117 slot-2)
118
119(defstruct test-struct-2
120 slot-1
121 slot-2)
122
123;;; Semantic specific macros
124;;
125(define-lex a-lexer
126 "Doc String"
127 this
128 that)
129
130(define-mode-local-override a-overriden-function
131 emacs-lisp-mode (tag)
132 "A function that is overloaded."
133 nil)
134
135(defvar-mode-local emacs-lisp-mode a-mode-local-def
136 "some value")
137
138
139;;; Provide
140;;
141(provide 'test)
diff --git a/test/cedet/tests/test.make b/test/cedet/tests/test.make
new file mode 100644
index 00000000000..6f1a4a386ee
--- /dev/null
+++ b/test/cedet/tests/test.make
@@ -0,0 +1,60 @@
1# Test makefile -*- makefile -*-
2
3top=
4ede_FILES=Project.ede Makefile
5
6example_MISC=semantic-skel.el skeleton.bnf
7init_LISP=semantic-load.el
8DISTDIR=$(top)semantic-$(VERSION)
9
10# really goofy & variables tabs
11A= B
12A =B
13A=B C
14A=B\
15 C
16
17A= http://${B} \
18 ftp://${B}
19B= test
20
21all: example semantic Languages tools senator semantic.info
22
23test ${B}: foo bar
24 @echo ${A}
25
26example:
27 @
28
29init: $(init_LISP)
30 @echo "(add-to-list 'load-path nil)" > $@-compile-script
31 @if test ! -z "${LOADPATH}" ; then\
32 for loadpath in ${LOADPATH}; do \
33 echo "(add-to-list 'load-path \"$$loadpath\")" >> $@-compile-script; \
34 done;\
35 fi
36 @echo "(setq debug-on-error t)" >> $@-compile-script
37 $(EMACS) -batch -l $@-compile-script -f batch-byte-compile $^
38
39include tesset.mk tusset.mk
40include oneset.mk
41
42ifdef SOME_SYMBOL
43 VAR1 = foo
44else
45 VAR1 = bar
46endif
47
48ifndef SOME_OTHER_SYMBOL
49 VAR1 = baz
50endif
51
52ifeq ($(VAR1), foo)
53 VAR2 = gleep
54else
55 ifneq ($(VAR1), foo)
56 VAR2 = glop
57 endif
58endif
59
60# End of Makefile
diff --git a/test/cedet/tests/test.py b/test/cedet/tests/test.py
new file mode 100644
index 00000000000..a7fee71074e
--- /dev/null
+++ b/test/cedet/tests/test.py
@@ -0,0 +1,579 @@
1# Test file for Python language.
2#
3# $Id: test.py,v 1.4 2007/03/08 02:16:33 zappo Exp $
4
5# Simle class compount statement with blank lines sprinkled.
6class Foo(Bar):
7
8 x = 1
9
10 y = 2
11
12# Simple def statement with no argument
13def sss():
14 i = 1
15
16# Simple def statement with arguments
17def ttt(x,y,z):
18 i = 1
19
20import foo
21
22for x in y:
23 print x
24
25while y > 0:
26 y = y - 1
27
28a=b=c=d=e=f=i=j=k=l=m=n=o=p=q=r=s=t=x=y=1
29
30if x:
31 x = 2
32 y = 3
33
34x = 2
35y = 3
36s and t
37q | r
38o ^ p
39m & n
40k << l
41z = 4
42i >> j
43e / f
44c * d
45a + b
462 ** 5
47x
48s = "a" "b" "c"
491
50
51# implicit continuation lines, see
52# http://docs.python.org/ref/implicit-joining.html
53
54a_list = [ 1, 2, 3,
55 4, 5,
56 6 ]
57
58a_tuple = (1, 2, 3,
59
60 4, 5, 6)
61
62a_hash = { 'a':1, "b":2,
63 'c' : 3,
64 "d" : 4 }
65
66
67def longarglist(a,
68 b,
69 c,
70 d):
71 a=1;
72 b=1;
73 c=1;
74 d=1;
75
76class longclasslist(xx.yyy,
77 zz.aa):
78 foo=1
79
80
81# wisent-python.wy chokes on this! -ryk 6/17/02
82
83class HTTPServer(xxx.yyy):
84 allow_reuse_address = 1 # Seems to make sense in testing environment
85 def server_bind(self):
86 SocketServer.TCPServer.server_bind(self)
87 host, port = self.socket.getsockname()
88 self.server_name = socket.getfqdn(host)
89 self.server_port = port
90
91
92#########################################################################
93### /usr/lib/python2.2/BaseHTTPServer.py
94#########################################################################
95
96"""HTTP server base class.
97
98Note: the class in this module doesn't implement any HTTP request; see
99SimpleHTTPServer for simple implementations of GET, HEAD and POST
100(including CGI scripts).
101
102Contents:
103
104- BaseHTTPRequestHandler: HTTP request handler base class
105- test: test function
106
107XXX To do:
108
109- send server version
110- log requests even later (to capture byte count)
111- log user-agent header and other interesting goodies
112- send error log to separate file
113- are request names really case sensitive?
114
115"""
116
117
118# See also:
119#
120# HTTP Working Group T. Berners-Lee
121# INTERNET-DRAFT R. T. Fielding
122# <draft-ietf-http-v10-spec-00.txt> H. Frystyk Nielsen
123# Expires September 8, 1995 March 8, 1995
124#
125# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt
126
127
128# Log files
129# ---------
130#
131# Here's a quote from the NCSA httpd docs about log file format.
132#
133# | The logfile format is as follows. Each line consists of:
134# |
135# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb
136# |
137# | host: Either the DNS name or the IP number of the remote client
138# | rfc931: Any information returned by identd for this person,
139# | - otherwise.
140# | authuser: If user sent a userid for authentication, the user name,
141# | - otherwise.
142# | DD: Day
143# | Mon: Month (calendar name)
144# | YYYY: Year
145# | hh: hour (24-hour format, the machine's timezone)
146# | mm: minutes
147# | ss: seconds
148# | request: The first line of the HTTP request as sent by the client.
149# | ddd: the status code returned by the server, - if not available.
150# | bbbb: the total number of bytes sent,
151# | *not including the HTTP/1.0 header*, - if not available
152# |
153# | You can determine the name of the file accessed through request.
154#
155# (Actually, the latter is only true if you know the server configuration
156# at the time the request was made!)
157
158
159__version__ = "0.2"
160
161__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
162
163import sys
164import time
165import socket # For gethostbyaddr()
166import mimetools
167import SocketServer
168
169# Default error message
170DEFAULT_ERROR_MESSAGE = """\
171<head>
172<title>Error response</title>
173</head>
174<body>
175<h1>Error response</h1>
176<p>Error code %(code)d.
177<p>Message: %(message)s.
178<p>Error code explanation: %(code)s = %(explain)s.
179</body>
180"""
181
182
183class HTTPServer(SocketServer.TCPServer):
184
185 allow_reuse_address = 1 # Seems to make sense in testing environment
186
187 def server_bind(self):
188 """Override server_bind to store the server name."""
189 SocketServer.TCPServer.server_bind(self)
190 host, port = self.socket.getsockname()
191 self.server_name = socket.getfqdn(host)
192 self.server_port = port
193
194
195class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
196
197 """HTTP request handler base class.
198
199 The following explanation of HTTP serves to guide you through the
200 code as well as to expose any misunderstandings I may have about
201 HTTP (so you don't need to read the code to figure out I'm wrong
202 :-).
203
204 HTTP (HyperText Transfer Protocol) is an extensible protocol on
205 top of a reliable stream transport (e.g. TCP/IP). The protocol
206 recognizes three parts to a request:
207
208 1. One line identifying the request type and path
209 2. An optional set of RFC-822-style headers
210 3. An optional data part
211
212 The headers and data are separated by a blank line.
213
214 The first line of the request has the form
215
216 <command> <path> <version>
217
218 where <command> is a (case-sensitive) keyword such as GET or POST,
219 <path> is a string containing path information for the request,
220 and <version> should be the string "HTTP/1.0". <path> is encoded
221 using the URL encoding scheme (using %xx to signify the ASCII
222 character with hex code xx).
223
224 The protocol is vague about whether lines are separated by LF
225 characters or by CRLF pairs -- for compatibility with the widest
226 range of clients, both should be accepted. Similarly, whitespace
227 in the request line should be treated sensibly (allowing multiple
228 spaces between components and allowing trailing whitespace).
229
230 Similarly, for output, lines ought to be separated by CRLF pairs
231 but most clients grok LF characters just fine.
232
233 If the first line of the request has the form
234
235 <command> <path>
236
237 (i.e. <version> is left out) then this is assumed to be an HTTP
238 0.9 request; this form has no optional headers and data part and
239 the reply consists of just the data.
240
241 The reply form of the HTTP 1.0 protocol again has three parts:
242
243 1. One line giving the response code
244 2. An optional set of RFC-822-style headers
245 3. The data
246
247 Again, the headers and data are separated by a blank line.
248
249 The response code line has the form
250
251 <version> <responsecode> <responsestring>
252
253 where <version> is the protocol version (always "HTTP/1.0"),
254 <responsecode> is a 3-digit response code indicating success or
255 failure of the request, and <responsestring> is an optional
256 human-readable string explaining what the response code means.
257
258 This server parses the request and the headers, and then calls a
259 function specific to the request type (<command>). Specifically,
260 a request SPAM will be handled by a method do_SPAM(). If no
261 such method exists the server sends an error response to the
262 client. If it exists, it is called with no arguments:
263
264 do_SPAM()
265
266 Note that the request name is case sensitive (i.e. SPAM and spam
267 are different requests).
268
269 The various request details are stored in instance variables:
270
271 - client_address is the client IP address in the form (host,
272 port);
273
274 - command, path and version are the broken-down request line;
275
276 - headers is an instance of mimetools.Message (or a derived
277 class) containing the header information;
278
279 - rfile is a file object open for reading positioned at the
280 start of the optional input data part;
281
282 - wfile is a file object open for writing.
283
284 IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!
285
286 The first thing to be written must be the response line. Then
287 follow 0 or more header lines, then a blank line, and then the
288 actual data (if any). The meaning of the header lines depends on
289 the command executed by the server; in most cases, when data is
290 returned, there should be at least one header line of the form
291
292 Content-type: <type>/<subtype>
293
294 where <type> and <subtype> should be registered MIME types,
295 e.g. "text/html" or "text/plain".
296
297 """
298
299 # The Python system version, truncated to its first component.
300 sys_version = "Python/" + sys.version.split()[0]
301
302 # The server software version. You may want to override this.
303 # The format is multiple whitespace-separated strings,
304 # where each string is of the form name[/version].
305 server_version = "BaseHTTP/" + __version__
306
307 def parse_request(self):
308 """Parse a request (internal).
309
310 The request should be stored in self.raw_request; the results
311 are in self.command, self.path, self.request_version and
312 self.headers.
313
314 Return value is 1 for success, 0 for failure; on failure, an
315 error is sent back.
316
317 """
318 self.request_version = version = "HTTP/0.9" # Default
319 requestline = self.raw_requestline
320 if requestline[-2:] == '\r\n':
321 requestline = requestline[:-2]
322 elif requestline[-1:] == '\n':
323 requestline = requestline[:-1]
324 self.requestline = requestline
325 words = requestline.split()
326 if len(words) == 3:
327 [command, path, version] = words
328 if version[:5] != 'HTTP/':
329 self.send_error(400, "Bad request version (%s)" % `version`)
330 return 0
331 elif len(words) == 2:
332 [command, path] = words
333 if command != 'GET':
334 self.send_error(400,
335 "Bad HTTP/0.9 request type (%s)" % `command`)
336 return 0
337 else:
338 self.send_error(400, "Bad request syntax (%s)" % `requestline`)
339 return 0
340 self.command, self.path, self.request_version = command, path, version
341 self.headers = self.MessageClass(self.rfile, 0)
342 return 1
343
344 def handle(self):
345 """Handle a single HTTP request.
346
347 You normally don't need to override this method; see the class
348 __doc__ string for information on how to handle specific HTTP
349 commands such as GET and POST.
350
351 """
352
353 self.raw_requestline = self.rfile.readline()
354 if not self.parse_request(): # An error code has been sent, just exit
355 return
356 mname = 'do_' + self.command
357 if not hasattr(self, mname):
358 self.send_error(501, "Unsupported method (%s)" % `self.command`)
359 return
360 method = getattr(self, mname)
361 method()
362
363 def send_error(self, code, message=None):
364 """Send and log an error reply.
365
366 Arguments are the error code, and a detailed message.
367 The detailed message defaults to the short entry matching the
368 response code.
369
370 This sends an error response (so it must be called before any
371 output has been generated), logs the error, and finally sends
372 a piece of HTML explaining the error to the user.
373
374 """
375
376 try:
377 short, long = self.responses[code]
378 except KeyError:
379 short, long = '???', '???'
380 if not message:
381 message = short
382 explain = long
383 self.log_error("code %d, message %s", code, message)
384 self.send_response(code, message)
385 self.send_header("Content-Type", "text/html")
386 self.end_headers()
387 self.wfile.write(self.error_message_format %
388 {'code': code,
389 'message': message,
390 'explain': explain})
391
392 error_message_format = DEFAULT_ERROR_MESSAGE
393
394 def send_response(self, code, message=None):
395 """Send the response header and log the response code.
396
397 Also send two standard headers with the server software
398 version and the current date.
399
400 """
401 self.log_request(code)
402 if message is None:
403 if self.responses.has_key(code):
404 message = self.responses[code][0]
405 else:
406 message = ''
407 if self.request_version != 'HTTP/0.9':
408 self.wfile.write("%s %s %s\r\n" %
409 (self.protocol_version, str(code), message))
410 self.send_header('Server', self.version_string())
411 self.send_header('Date', self.date_time_string())
412
413 def send_header(self, keyword, value):
414 """Send a MIME header."""
415 if self.request_version != 'HTTP/0.9':
416 self.wfile.write("%s: %s\r\n" % (keyword, value))
417
418 def end_headers(self):
419 """Send the blank line ending the MIME headers."""
420 if self.request_version != 'HTTP/0.9':
421 self.wfile.write("\r\n")
422
423 def log_request(self, code='-', size='-'):
424 """Log an accepted request.
425
426 This is called by send_reponse().
427
428 """
429
430 self.log_message('"%s" %s %s',
431 self.requestline, str(code), str(size))
432
433 def log_error(self, *args):
434 """Log an error.
435
436 This is called when a request cannot be fulfilled. By
437 default it passes the message on to log_message().
438
439 Arguments are the same as for log_message().
440
441 XXX This should go to the separate error log.
442
443 """
444
445 apply(self.log_message, args)
446
447 def log_message(self, format, *args):
448 """Log an arbitrary message.
449
450 This is used by all other logging functions. Override
451 it if you have specific logging wishes.
452
453 The first argument, FORMAT, is a format string for the
454 message to be logged. If the format string contains
455 any % escapes requiring parameters, they should be
456 specified as subsequent arguments (it's just like
457 printf!).
458
459 The client host and current date/time are prefixed to
460 every message.
461
462 """
463
464 sys.stderr.write("%s - - [%s] %s\n" %
465 (self.address_string(),
466 self.log_date_time_string(),
467 format%args))
468
469 def version_string(self):
470 """Return the server software version string."""
471 return self.server_version + ' ' + self.sys_version
472
473 def date_time_string(self):
474 """Return the current date and time formatted for a message header."""
475 now = time.time()
476 year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now)
477 s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
478 self.weekdayname[wd],
479 day, self.monthname[month], year,
480 hh, mm, ss)
481 return s
482
483 def log_date_time_string(self):
484 """Return the current time formatted for logging."""
485 now = time.time()
486 year, month, day, hh, mm, ss, x, y, z = time.localtime(now)
487 s = "%02d/%3s/%04d %02d:%02d:%02d" % (
488 day, self.monthname[month], year, hh, mm, ss)
489 return s
490
491 weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
492
493 monthname = [None,
494 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
495 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
496
497 def address_string(self):
498 """Return the client address formatted for logging.
499
500 This version looks up the full hostname using gethostbyaddr(),
501 and tries to find a name that contains at least one dot.
502
503 """
504
505 host, port = self.client_address
506 return socket.getfqdn(host)
507
508 # Essentially static class variables
509
510 # The version of the HTTP protocol we support.
511 # Don't override unless you know what you're doing (hint: incoming
512 # requests are required to have exactly this version string).
513 protocol_version = "HTTP/1.0"
514
515 # The Message-like class used to parse headers
516 MessageClass = mimetools.Message
517
518 # Table mapping response codes to messages; entries have the
519 # form {code: (shortmessage, longmessage)}.
520 # See http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html
521 responses = {
522 200: ('OK', 'Request fulfilled, document follows'),
523 201: ('Created', 'Document created, URL follows'),
524 202: ('Accepted',
525 'Request accepted, processing continues off-line'),
526 203: ('Partial information', 'Request fulfilled from cache'),
527 204: ('No response', 'Request fulfilled, nothing follows'),
528
529 301: ('Moved', 'Object moved permanently -- see URI list'),
530 302: ('Found', 'Object moved temporarily -- see URI list'),
531 303: ('Method', 'Object moved -- see Method and URL list'),
532 304: ('Not modified',
533 'Document has not changed singe given time'),
534
535 400: ('Bad request',
536 'Bad request syntax or unsupported method'),
537 401: ('Unauthorized',
538 'No permission -- see authorization schemes'),
539 402: ('Payment required',
540 'No payment -- see charging schemes'),
541 403: ('Forbidden',
542 'Request forbidden -- authorization will not help'),
543 404: ('Not found', 'Nothing matches the given URI'),
544
545 500: ('Internal error', 'Server got itself in trouble'),
546 501: ('Not implemented',
547 'Server does not support this operation'),
548 502: ('Service temporarily overloaded',
549 'The server cannot process the request due to a high load'),
550 503: ('Gateway timeout',
551 'The gateway server did not receive a timely response'),
552
553 }
554
555
556def test(HandlerClass = BaseHTTPRequestHandler,
557 ServerClass = HTTPServer):
558 """Test the HTTP request handler class.
559
560 This runs an HTTP server on port 8000 (or the first command line
561 argument).
562
563 """
564
565 if sys.argv[1:]:
566 port = int(sys.argv[1])
567 else:
568 port = 8000
569 server_address = ('', port)
570
571 httpd = ServerClass(server_address, HandlerClass)
572
573 sa = httpd.socket.getsockname()
574 print "Serving HTTP on", sa[0], "port", sa[1], "..."
575 httpd.serve_forever()
576
577
578if __name__ == '__main__':
579 test()
diff --git a/test/cedet/tests/testdoublens.cpp b/test/cedet/tests/testdoublens.cpp
new file mode 100644
index 00000000000..1cf48761ac7
--- /dev/null
+++ b/test/cedet/tests/testdoublens.cpp
@@ -0,0 +1,148 @@
1//
2// CPP file for semantic-ia-utest
3// completion engine unit tests.
4//
5#include "testdoublens.hpp"
6
7namespace Name1 {
8 namespace Name2 {
9
10 Foo::Foo()
11 {
12 p// -1-
13 // #1# ( "pMumble" "publishStuff" )
14 ;
15 }
16
17 int Foo::get() // ^1^
18 {
19 p// -2-
20 // #2# ( "pMumble" "publishStuff" )
21 ;
22 return 0;
23 }
24
25 void Foo::publishStuff(int /* a */, int /* b */) // ^2^
26 {
27 }
28
29 void Foo::sendStuff(int /* a */, int /* b */) // ^3^
30 {
31 }
32
33 } // namespace Name2
34} // namespace Name1
35
36// Test multiple levels of metatype expansion
37int test_fcn () {
38 stage3_Foo MyFoo;
39
40 MyFoo.// -3-
41 // #3# ( "Mumble" "get" )
42 ;
43
44 Name1::Name2::F//-4-
45 // #4# ( "Foo" )
46 ;
47
48 // @TODO - get this working...
49 Name1::stage2_Foo::M//-5-
50 /// #5# ( "Mumble" )
51 ;
52}
53
54stage3_Foo foo_fcn() {
55 // Can we go "up" to foo with senator-go-to-up-reference?
56}
57
58
59// Second test from Ravikiran Rajagopal
60
61namespace A {
62 class foo {
63 public:
64 void aa();
65 void bb();
66 };
67}
68namespace A {
69 class bar {
70 public:
71 void xx();
72 public:
73 foo myFoo;
74 };
75
76 void bar::xx()
77 {
78 myFoo.// -6- <--- cursor is here after the dot
79 // #6# ( "aa" "bb" )
80 ;
81 }
82}
83
84// Double namespace example from Hannu Koivisto
85//
86// This is tricky because the parent class "Foo" is found within the
87// scope of B, so the scope calculation needs to put that together
88// before searching for parents in scope.
89namespace a {
90 namespace b {
91
92 class Bar : public Foo
93 {
94 int baz();
95 };
96
97 int Bar::baz()
98 {
99 return dum// -7-
100 // #7# ( "dumdum" )
101 ;
102 }
103
104 } // namespace b
105} // namespace a
106
107// Three namespace example from Hannu Koivisto
108//
109// This one is special in that the name e::Foo, where "e" is in
110// the scope, and not referenced from the global namespace. This
111// wasn't previously handled, so the fullscope needed to be added
112// to the list of things searched when in split-name decent search mode
113// for scopes.
114
115namespace d {
116 namespace e {
117
118 class Foo
119 {
120 public:
121 int write();
122 };
123
124 } // namespace d
125} // namespace e
126
127
128namespace d {
129 namespace f {
130
131 class Bar
132 {
133 public:
134 int baz();
135
136 private:
137 e::Foo &foo;
138 };
139
140 int Bar::baz()
141 {
142 return foo.w// -8-
143 // #8# ( "write" )
144 ;
145 }
146
147 } // namespace f
148} // namespace d
diff --git a/test/cedet/tests/testdoublens.hpp b/test/cedet/tests/testdoublens.hpp
new file mode 100644
index 00000000000..3f9a8a251c3
--- /dev/null
+++ b/test/cedet/tests/testdoublens.hpp
@@ -0,0 +1,51 @@
1//
2// Header file used in one of the ia-utest tests.
3//
4namespace Name1 {
5 namespace Name2 {
6
7 class Foo
8 {
9 typedef unsigned int Mumble;
10 public:
11 Foo();
12 ~Foo();
13 int get();
14
15 private:
16 void publishStuff(int a, int b);
17
18 void sendStuff(int a, int b);
19
20 Mumble* pMumble;
21 };
22
23 typedef Foo stage1_Foo;
24
25 } // namespace Name2
26
27 typedef Name2::stage1_Foo stage2_Foo;
28
29 typedef Name2::Foo decl_stage1_Foo;
30
31} // namespace Name1
32
33typedef Name1::stage2_Foo stage3_Foo;
34
35
36// Double namespace from Hannu Koivisto
37namespace a {
38 namespace b {
39
40 class Foo
41 {
42 struct Dum {
43 int diDum;
44 };
45
46 protected:
47 mutable a::b::Foo::Dum dumdum;
48 };
49
50 } // namespace b
51} // namespace a
diff --git a/test/cedet/tests/testfriends.cpp b/test/cedet/tests/testfriends.cpp
new file mode 100644
index 00000000000..f84ed5a2190
--- /dev/null
+++ b/test/cedet/tests/testfriends.cpp
@@ -0,0 +1,37 @@
1// Test parsing of friends and how they are used in completion.
2/*
3 >> Thanks Damien Profeta for the nice example.
4 >
5 > I paste a small example.
6 > It would be great if friend can be well parsed and even greater if
7 > class B can access to all the members of A.
8*/
9
10class Af // %2% ( ( "testfriends.cpp" ) ( "Af" "B::testB" ) )
11{
12public:
13 int pubVar;
14private:
15 int privateVar;
16
17 friend class B;
18
19};
20
21class B
22{
23public:
24 int testB();
25 int testAB();
26
27};
28
29
30int B::testB() {
31 Af classA;
32 classA.//-1-
33 ; //#1# ( "privateVar" "pubVar" )
34}
35
36int B::testAB() { // %1% ( ( "testfriends.cpp" ) ( "B" "B::testAB" ) )
37}
diff --git a/test/cedet/tests/testjavacomp.java b/test/cedet/tests/testjavacomp.java
new file mode 100644
index 00000000000..cdb28d7f917
--- /dev/null
+++ b/test/cedet/tests/testjavacomp.java
@@ -0,0 +1,69 @@
1/** testjavacomp.java ---
2 *
3 * Copyright (C) 2009 Eric M. Ludlam
4 *
5 * Author: Eric M. Ludlam <eric@siege-engine.com>
6 * X-RCS: $Id: testjavacomp.java,v 1.1 2009/02/01 16:28:25 zappo Exp $
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2, or (at
11 * your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24package tests.testjavacomp;
25
26class secondClass {
27 private void scFuncOne() { }
28 public void scFuncOne() { }
29}
30
31
32public class testjavacomp {
33
34 private int funcOne() { }
35 private int funcTwo() { }
36 private char funcThree() { }
37
38 class nestedClass {
39 private void ncFuncOne() { }
40 public void ncFuncOne() { }
41 }
42
43 public void publicFunc() {
44
45 int i;
46
47 i = fu// -1-
48 // #1# ( "funcOne" "funcTwo" )
49 ;
50
51 fu// -2-
52 // #2# ( "funcOne" "funcThree" "funcTwo" )
53 ;
54
55 secondClass SC;
56
57 SC.//-3-
58 // #3# ( "scFuncOne" )
59 ;
60
61 nestedClass NC;
62
63 // @todo - need to fix this? I don't know if this is legal java.
64 NC.// - 4-
65 // #4# ( "ncFuncOne" )
66 ;
67 }
68
69} // testjavacomp
diff --git a/test/cedet/tests/testnsp.cpp b/test/cedet/tests/testnsp.cpp
new file mode 100644
index 00000000000..00723c693cd
--- /dev/null
+++ b/test/cedet/tests/testnsp.cpp
@@ -0,0 +1,28 @@
1// Test NSP (Name space parent)
2//
3// Test dereferencing parents based on local parent scope.
4//
5// Derived from data David Engster provided.
6
7namespace nsp {
8
9 class rootclass {
10 public:
11 int fromroot() {};
12 };
13
14}
15
16namespace nsp {
17 class childclass : public rootclass {
18 public:
19 int fromchild() {};
20 };
21}
22
23void myfcn_not_in_ns (void) {
24 nsp::childclass test;
25
26 test.// -1-
27 ; // #1# ( "fromchild" "fromroot" )
28}
diff --git a/test/cedet/tests/testpolymorph.cpp b/test/cedet/tests/testpolymorph.cpp
new file mode 100644
index 00000000000..9352ba78494
--- /dev/null
+++ b/test/cedet/tests/testpolymorph.cpp
@@ -0,0 +1,131 @@
1/** testpolymorph.cpp --- A sequence of polymorphism examples.
2 *
3 * Copyright (C) 2009 Eric M. Ludlam
4 *
5 * Author: Eric M. Ludlam <eric@siege-engine.com>
6 * X-RCS: $Id: testpolymorph.cpp,v 1.2 2009/09/02 13:55:46 davenar Exp $
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2, or (at
11 * your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#include <cmath>
25
26// Test 1 - Functions w/ prototypes
27namespace proto {
28
29 int pt_func1(int arg1);
30 int pt_func1(int arg1) {
31 return 0;
32 }
33
34}
35
36// Test 2 - Functions w/ different arg lists.
37namespace fcn_poly {
38
39 int pm_func(void) {
40 return 0;
41 }
42 int pm_func(int a) {
43 return a;
44 }
45 int pm_func(char a) {
46 return int(a);
47 }
48 int pm_func(double a) {
49 return int(floor(a));
50 }
51
52}
53
54// Test 3 - Methods w/ differet arg lists.
55class meth_poly {
56public:
57 int pm_meth(void) {
58 return 0;
59 }
60 int pm_meth(int a) {
61 return a;
62 }
63 int pm_meth(char a) {
64 return int(a);
65 }
66 int pm_meth(double a) {
67 return int(floor(a));
68 }
69
70};
71
72// Test 4 - Templates w/ partial specifiers.
73namespace template_partial_spec {
74 template <typename T> class test
75 {
76 public:
77 void doSomething(T t) { };
78 };
79
80 template <typename T> class test<T *>
81 {
82 public:
83 void doSomething(T* t) { };
84 };
85}
86
87// Test 5 - Templates w/ full specicialization which may or may not share
88// common functions.
89namespace template_full_spec {
90 template <typename T> class test
91 {
92 public:
93 void doSomething(T t) { };
94 void doSomethingElse(T t) { };
95 };
96
97 template <> class test<int>
98 {
99 public:
100 void doSomethingElse(int t) { };
101 void doSomethingCompletelyDifferent(int t) { };
102 };
103}
104
105// Test 6 - Dto., but for templates with multiple parameters.
106namespace template_multiple_spec {
107 template <typename T1, typename T2> class test
108 {
109 public:
110 void doSomething(T1 t) { };
111 void doSomethingElse(T2 t) { };
112 };
113
114 template <typename T2> class test<int, T2>
115 {
116 public:
117 void doSomething(int t) { };
118 void doSomethingElse(T2 t) { };
119 };
120
121 template <> class test<float, int>
122 {
123 public:
124 void doSomething(float t) { };
125 void doSomethingElse(int t) { };
126 void doNothing(void) { };
127 };
128}
129
130
131// End of polymorphism test file.
diff --git a/test/cedet/tests/testspp.c b/test/cedet/tests/testspp.c
new file mode 100644
index 00000000000..c7ff76203b2
--- /dev/null
+++ b/test/cedet/tests/testspp.c
@@ -0,0 +1,84 @@
1/* Attempt to test the C preprocessor
2 *
3 */
4
5int some_fcn (){}
6
7
8#ifndef MOOSE
9int pre_show_moose(){}
10#endif
11
12#ifdef MOOSE
13int pre_dont_show_moose(){}
14#endif
15
16#if !defined(MOOSE)
17int pre_show_moose_if(){}
18#endif
19
20#if defined(MOOSE)
21int pre_dont_show_moose_if(){}
22#endif
23
24#define MOOSE
25
26#if 0
27int dont_show_function_if_0(){}
28#endif
29
30#if 1
31int show_function_if_1(){}
32#endif
33
34#ifdef MOOSE
35int moose_function(){}
36#endif
37
38#ifndef MOOSE
39int dont_show_moose(){}
40#endif
41
42#if defined(MOOSE)
43int moose_function_if(){}
44#endif
45
46#if !defined(MOOSE)
47int dont_show_moose_if() {}
48#endif
49
50#undef MOOSE
51
52#ifdef MOOSE
53int no_handy_moose(){}
54#endif
55
56#ifndef MOOSE
57int show_moose_else() {}
58#else
59int no_show_moose_else(){}
60#endif
61
62
63#ifdef MOOSE
64int no_show_moose_else_2() {}
65#else
66int show_moose_else_2() {}
67#endif
68
69#if defined(MOOSE)
70int no_show_moose_elif() {}
71#elif !defined(MOOSE)
72int show_moose_elif() {}
73#else
74int no_show_moose_elif_else() {}
75#endif
76
77#if defined(MOOSE)
78int no_show_moose_if_elif_2() {}
79#elif defined(COW)
80int no_show_moose_elif_2() {}
81#else
82int show_moose_elif_else() {}
83#endif
84
diff --git a/test/cedet/tests/testsppcomplete.c b/test/cedet/tests/testsppcomplete.c
new file mode 100644
index 00000000000..4a37e885f22
--- /dev/null
+++ b/test/cedet/tests/testsppcomplete.c
@@ -0,0 +1,29 @@
1/* Example provided by Hannes Janetzek */
2
3struct Test { int test; };
4
5#define BLA(_type) \
6 _type *bla = (_type*) malloc(sizeof(_type));
7
8#define BLUB(_type) \
9 (_type*)malloc(sizeof(_type));
10
11#define FOO(_type) \
12 _type *foo = BLUB(_type);
13
14#define BAR(_type) \
15 _type *bar = (*_type)BLUB(_type);
16
17int main(int argc, char *argv[]) {
18 BLA(Test);
19 bla->// -1-
20 ; // #1# ( "test" )
21
22 FOO(Test);
23 foo->// -2-
24 ; // #2# ( "test" )
25
26 BAR(Test);
27 bar->// -3-
28 ; // #3# ( "test" )
29}
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 */
diff --git a/test/cedet/tests/testsppreplaced.c b/test/cedet/tests/testsppreplaced.c
new file mode 100644
index 00000000000..f4d8889409f
--- /dev/null
+++ b/test/cedet/tests/testsppreplaced.c
@@ -0,0 +1,97 @@
1/* What the SPP replace file would looklike with MACROS replaced.
2 */
3
4/* TEST: The EMU keyword doesn't screw up the function defn. */
5char parse_around_emu ()
6{
7}
8
9/* TEST: A simple word can be replaced in a definition. */
10float returnanfloat()
11{
12}
13
14/* TEST: Punctuation an be replaced in a definition. */
15int foo::bar ()
16{
17}
18
19/* TEST: Multiple lexical characters in a definition */
20int mysuper::baz ()
21{
22}
23
24/* TEST: Macro replacement. */
25int increment (int in) {
26 return in+1;
27}
28
29/* TEST: Macro replacement with complex args */
30int myFcn1 ();
31
32int myFcn2 (int a, int b);
33int myFcn3 (int a, int b);
34
35/* TEST: Multiple args to a macro. */
36struct ma_struct { int moose; int penguin; int emu; };
37
38/* TEST: Macro w/ args, but no body. */
39
40/* TEST: Not a macro with args, but close. */
41int not_with_args_fcn (moose)
42{
43}
44
45/* TEST: macro w/ continuation. */
46int continuation_symbol () { };
47
48/* TEST: macros in a macro - tail processing */
49
50int tail (int q) {}
51
52/* TEST: macros used impropertly. */
53
54int tail_fcn(int q);
55
56/* TEST: feature of CPP from LSD <lsdsgster@...> */
57
58int __gthrw_foo (int arg1) { }
59
60/* TEST: macros using macros */
61int foo;
62
63/* TEST: macros with args using macros */
64int noodle(int noodle);
65
66/* TEST: Double macro using the argument stack. */
67int that_foo(int i);
68int this_foo(int i);
69
70/* TEST: The G++ namespace macro hack. Not really part of SPP. */
71namespace baz {
72
73 int bazfnc(int b) { }
74
75}
76
77namespace foo { namespace bar {
78
79 int foo_bar_func(int a) { }
80
81 }
82}
83
84/* TEST: The VC++ macro hack. */
85namespace std {
86
87 int inside_std_namespace(int a) { }
88
89}
90
91/* TEST: Recursion prevention. CPP doesn't allow even 1 level of recursion. */
92int MACROA () {
93
94}
95
96
97/* End */
diff --git a/test/cedet/tests/teststruct.cpp b/test/cedet/tests/teststruct.cpp
new file mode 100644
index 00000000000..6bc27b97208
--- /dev/null
+++ b/test/cedet/tests/teststruct.cpp
@@ -0,0 +1,66 @@
1// Combinations of templates and structure inheritance.
2//
3// Created by Alex Ott.
4
5template <typename DerivedT>
6struct grammar {
7public:
8 typedef grammar<DerivedT> self_t;
9 typedef DerivedT const& embed_t;
10 grammar() {}
11 ~grammar() { }
12 void use_parser() const { }
13 void test1() { }
14};
15
16struct PDFbool_parser : public grammar<PDFbool_parser> {
17 PDFbool_parser() {}
18 template <typename scannerT> struct definition {
19 typedef typename scannerT::iterator_t iterator_t;
20 int top;
21 definition(const PDFbool_parser& /*self*/) {
22 return ;
23 }
24 const int start() const {
25 return top;
26 }
27 };
28};
29
30int main(void) {
31 PDFbool_parser PDFbool_p = PDFbool_parser();
32 PDFbool_p.//-1-
33 ;
34 // #1# ("definition" "embed_t" "self_t" "test1" "use_parser")
35}
36
37// ----------------------------------------------------------------------
38
39template <class Derived> struct Base {
40public:
41 void interface()
42 {
43 // ...
44 static_cast<Derived*>(this)->implementation();
45 // ...
46 }
47
48 static void static_func()
49 {
50 // ...
51 Derived::static_sub_func();
52 // ...
53 }
54};
55
56struct Derived : Base<Derived> {
57 void implementation() { }
58 static void static_sub_func() { }
59};
60
61int foo () {
62 Derived d;
63 d.//-2-
64 ;
65 // #2# ("implementation" "interface" "static_func" "static_sub_func")
66}
diff --git a/test/cedet/tests/testsubclass.cpp b/test/cedet/tests/testsubclass.cpp
new file mode 100644
index 00000000000..30da4a85987
--- /dev/null
+++ b/test/cedet/tests/testsubclass.cpp
@@ -0,0 +1,231 @@
1/* Special test file for Semantic Analyzer and complex C++ inheritance.
2 */
3
4//#include <iostream>
5#include "testsubclass.hh"
6
7void animal::moose::setFeet(int numfeet) //^1^
8{
9 if (numfeet > 4) {
10 std::cerr << "Why would a moose have more than 4 feet?" << std::endl;
11 return;
12 }
13
14 fFeet = numfeet;
15}
16
17int animal::moose::getFeet() //^2^
18{
19 return fFeet;
20}
21
22void animal::moose::doNothing() //^3^
23{
24 animal::moose foo();
25
26 fFeet = N// -15-
27 ; // #15# ( "NAME1" "NAME2" "NAME3" )
28}
29
30
31void deer::moose::setAntlers(bool have_antlers) //^4^
32{
33 fAntlers = have_antlers;
34}
35
36bool deer::moose::getAntlers() //^5^
37// %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) )
38{
39 return fAntlers;
40}
41
42bool i_dont_have_symrefs()
43// %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs"))
44{
45}
46
47void deer::moose::doSomething() //^6^
48{
49 // All these functions should be identified by semantic analyzer.
50 getAntlers();
51 setAntlers(true);
52
53 getFeet();
54 setFeet(true);
55
56 doNothing();
57
58 fSomeField = true;
59
60 fIsValid = true;
61}
62
63void deer::alces::setLatin(bool l) {
64 fLatin = l;
65}
66
67bool deer::alces::getLatin() {
68 return fLatin;
69}
70
71void deer::alces::doLatinStuff(moose moosein) {
72 // All these functions should be identified by semantic analyzer.
73 getFeet();
74 setFeet(true);
75
76 getLatin();
77 setLatin(true);
78
79 doNothing();
80
81 deer::moose foo();
82
83
84}
85
86moose deer::alces::createMoose()
87{
88 moose MooseVariableName;
89 bool tmp;
90 int itmp;
91 bool fool;
92 int fast;
93
94 MooseVariableName = createMoose();
95
96 doLatinStuff(MooseVariableName);
97
98 tmp = this.f// -1-
99 // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
100 ;
101
102 itmp = this.f// -2-
103 // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
104 ;
105
106 tmp = f// -3-
107 // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
108 ;
109
110 itmp = f// -4-
111 // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
112 ;
113
114 MooseVariableName = m// -5-
115 // #5# ( "moose" )
116
117 return MooseVariableName;
118}
119
120/** Test Scope Changes
121 *
122 * This function is rigged to make sure the scope changes to account
123 * for different locations in local variable parsing.
124 */
125int someFunction(int mPickle)
126{
127 moose mMoose = deer::alces::createMoose();
128
129 if (mPickle == 1) {
130
131 int mOption1 = 2;
132
133 m// -5-
134 // #5# ( "mMoose" "mOption1" "mPickle" )
135 ;
136
137 } else {
138
139 int mOption2 = 2;
140
141 m// -6-
142 // #6# ( "mMoose" "mOption2" "mPickle" )
143 ;
144 }
145
146}
147
148// Thanks Ming-Wei Chang for this next example.
149
150namespace pub_priv {
151
152 class A{
153 private:
154 void private_a(){}
155 public:
156 void public_a();
157 };
158
159 void A::public_a() {
160 A other_a;
161
162 other_a.p// -7-
163 // #7# ( "private_a" "public_a" )
164 ;
165 }
166
167 int some_regular_function(){
168 A a;
169 a.p// -8-
170 // #8# ( "public_a" )
171 ;
172 return 0;
173 }
174
175}
176
177
178/** Test Scope w/in a function (non-method) with classes using
179 * different levels of inheritance.
180 */
181int otherFunction()
182{
183 sneaky::antelope Antelope(1);
184 sneaky::jackalope Jackalope(1);
185 sneaky::bugalope Bugalope(1);
186
187 Antelope.// -9-
188 // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
189 ;
190
191 Jackalope.// -10-
192 // #10# ( "fBunnyPublic" "testAccess")
193 ;
194
195 Jackalope// @1@ 6
196 ;
197 Jackalope;
198 Jackalope;
199 Jackalope;
200
201 Bugalope.// -11-
202 // #11# ( "fBugPublic" "testAccess")
203 ;
204 Bugalope// @2@ 3
205 ;
206}
207
208/** Test methods within each class for types of access to the baseclass.
209 */
210
211bool sneaky::antelope::testAccess() //^7^
212{
213 this.// -12-
214 // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
215 ;
216}
217
218bool sneaky::jackalope::testAccess() //^8^
219{
220 this.// -13-
221 // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
222 ;
223}
224
225bool sneaky::bugalope::testAccess() //^9^
226{
227 this.// -14-
228 // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )
229 ;
230}
231
diff --git a/test/cedet/tests/testsubclass.hh b/test/cedet/tests/testsubclass.hh
new file mode 100644
index 00000000000..8c9886d55f1
--- /dev/null
+++ b/test/cedet/tests/testsubclass.hh
@@ -0,0 +1,175 @@
1/* Special test file for Semantic Analyzer and complex C++ inheritance.
2 *
3 * Header file for testsubclass.cpp with class defns but no
4 * implementations.
5 */
6
7//#include <cmath>
8// #include <stdio.h>
9
10#ifndef TESTSUBCLASS_HH
11#define TESTSUBCLASS_HH
12
13namespace animal {
14
15 class moose {
16 public:
17 moose() : fFeet(0),
18 fIsValid(false)
19 { }
20
21 virtual void setFeet(int);
22 int getFeet();
23
24 void doNothing();
25
26 enum moose_enum {
27 NAME1, NAME2, NAME3 };
28
29
30 protected:
31
32 bool fIsValid;
33 int fIsProtectedInt;
34
35 private:
36 int fFeet; // Usually 2 or 4.
37 bool fIsPrivateBool;
38
39 }; // moose
40
41 int two_prototypes();
42 int two_prototypes();
43
44 class quadruped {
45 public:
46 quadruped(int a) : fQuadPrivate(a)
47 { }
48
49 int fQuadPublic;
50
51 protected:
52 int fQuadProtected;
53
54 private:
55 int fQuadPrivate;
56
57 };
58
59}
60
61
62namespace deer {
63
64 class moose : public animal::moose {
65 public:
66 moose() : fAntlers(false)
67 { }
68
69 void setAntlers(bool);
70 bool getAntlers();
71
72 void doSomething();
73
74 protected:
75
76 bool fSomeField;
77
78 private:
79 bool fAntlers;
80
81 };
82
83} // deer
84
85// A second namespace of the same name will test the
86// namespace merging needed to resolve deer::alces
87namespace deer {
88
89 class alces : public animal::moose {
90 public:
91 alces(int lat) : fLatin(lat)
92 { }
93
94 void setLatin(bool);
95 bool getLatin();
96
97 void doLatinStuff(moose moosein); // for completion testing
98
99 moose createMoose(); // for completion testing.
100
101 protected:
102 bool fAlcesBool;
103 int fAlcesInt;
104
105 private:
106 bool fLatin;
107 int fGreek;
108 };
109
110};
111
112// A third namespace with classes that does protected and private inheritance.
113namespace sneaky {
114
115 class antelope : public animal::quadruped {
116
117 public:
118 antelope(int a) : animal::quadruped(),
119 fAntyProtected(a)
120 {}
121
122 int fAntyPublic;
123
124 bool testAccess();
125
126 protected:
127 int fAntyProtected;
128
129 private :
130 int fAntyPrivate;
131
132 };
133
134 class jackalope : protected animal::quadruped {
135
136 public:
137 jackalope(int a) : animal::quadruped(),
138 fBunny(a)
139 {}
140
141 int fBunnyPublic;
142
143 bool testAccess();
144
145 protected:
146 bool fBunnyProtected;
147
148 private :
149 bool fBunnyPrivate;
150
151 };
152
153 // Nothing specified means private.
154 class bugalope : /* private*/ animal::quadruped {
155
156 public:
157 bugalope(int a) : animal::quadruped(),
158 fBug(a)
159 {}
160
161 int fBugPublic;
162
163 bool testAccess();
164 protected:
165 bool fBugProtected;
166
167 private :
168 bool fBugPrivate;
169
170 };
171
172
173};
174
175#endif
diff --git a/test/cedet/tests/testtemplates.cpp b/test/cedet/tests/testtemplates.cpp
new file mode 100644
index 00000000000..4ffb71c718c
--- /dev/null
+++ b/test/cedet/tests/testtemplates.cpp
@@ -0,0 +1,90 @@
1// Templates Test file:
2// Written by 'Raf'
3
4template <class T, int U, class V>
5class read_ref {
6public:
7 const T* read_ref_member_one( T);
8 const V* read_ref_member_two();
9};
10
11namespace NS {
12 template <class T, int U, class V>
13 class ref {
14 public:
15 read_ref<T,10,V> operator->() {
16 m_// -1-
17 ;
18 // #1# ( "m_datas" )
19 }
20
21 private:
22 T m_datas[U];
23 };
24
25}
26
27class FooOne {
28public:
29 int fooOneMember();
30};
31
32class FooTwo {
33public:
34 int fooTwoMember();
35};
36
37class FooThree {
38public:
39 int fooThreeMember();
40
41 FooOne * operator->();
42};
43
44typedef ref<FooOne, 10,FooTwo> Test;
45
46using NS;
47
48void
49main(void) {
50 ref<FooOne, 10, FooTwo> v;
51
52 v->read_ref_member_one()-> // -2-
53 ;
54 // #2# ( "fooOneMember" )
55
56 v->read_ref_member_two()-> // -3-
57 ;
58 // #3# ( "fooTwoMember" )
59
60 v-> // -4-
61 ;
62 // #4# ( "read_ref_member_one" "read_ref_member_two" )
63
64 Test t;
65
66 t->read_ref_member_two()-> // -5-
67 ;
68 // #5# ( "fooTwoMember" )
69
70 ref<FooOne, 10, FooThree> v2;
71
72 v2->read_ref_member_two()-> // -6-
73 ;
74 // #6# ( "fooOneMember" )
75
76 /* Try all these things by also specifying the namespace in the name. */
77 NS::ref<FooOne, 10, FooTwo> v3;
78
79 v3->read_ref_member_one()-> // -7-
80 ;
81 // #7# ( "fooOneMember" )
82
83 v3->read_ref_member_two()-> // -8-
84 ;
85 // #8# ( "fooTwoMember" )
86
87 v3->read_ref_member_two// @1@ 5
88 ;
89
90}
diff --git a/test/cedet/tests/testtypedefs.cpp b/test/cedet/tests/testtypedefs.cpp
new file mode 100644
index 00000000000..35965a6ad60
--- /dev/null
+++ b/test/cedet/tests/testtypedefs.cpp
@@ -0,0 +1,74 @@
1// Sample with some fake bits out of std::string
2//
3// Thanks Ming-Wei Chang for these examples.
4
5namespace std {
6
7 template <T>class basic_string {
8
9 public:
10 void resize(int);
11
12 };
13
14}
15
16typedef std::basic_string<char> mstring;
17
18using namespace std;
19typedef basic_string<char> bstring;
20
21
22int main(){
23 mstring a;
24
25 a.// -1-
26 ;
27 // #1# ( "resize" )
28
29 bstring b;
30 // It doesn't work here.
31 b.// -2-
32 ;
33 // #2# ( "resize" )
34
35 return 0;
36}
37
38
39// ------------------
40
41class Bar
42{
43public:
44 void someFunc() {}
45
46};
47
48typedef Bar new_Bar;
49
50template <class mytype>
51class TBar
52{
53public:
54 void otherFunc() {}
55
56};
57
58typedef TBar<char> new_TBar;
59
60int main()
61{
62 new_Bar nb;
63 new_TBar ntb;
64
65 nb.// -3-
66 ;
67 // #3# ("someFunc")
68
69 ntb.// -4-
70 ;
71 // #4# ("otherFunc")
72
73 return 0;
74}
diff --git a/test/cedet/tests/testusing.cpp b/test/cedet/tests/testusing.cpp
new file mode 100644
index 00000000000..b35f3a13063
--- /dev/null
+++ b/test/cedet/tests/testusing.cpp
@@ -0,0 +1,132 @@
1// Test using statements in C++
2
3#include <adstdio.h>
4
5#include <testusing.hh>
6
7namespace moose {
8
9 class MyClass;
10 class Point;
11
12 typedef MyClass snerk;
13}
14
15namespace moose {
16
17 class Point;
18 class MyClass;
19
20}
21
22namespace {
23
24 int global_variable = 0;
25
26};
27
28using moose::MyClass;
29
30void someFcn() {
31
32 MyClass f;
33
34 f.//-1-
35 ; //#1# ( "getVal" "setVal" )
36
37}
38
39// Code from Zhiqiu Kong
40
41namespace panda {
42
43 using namespace bread_name;
44
45 int func()
46 {
47 bread test;
48 test.//-2-
49 ;// #2# ( "geta" )
50 return 0;
51 }
52}
53
54// Local using statements and aliased types
55// Code from David Engster
56
57void func2()
58{
59 using namespace somestuff;
60 OneClass f;
61 f.//-3-
62 ; //#3# ( "aFunc" "anInt" )
63}
64
65void func3()
66{
67 using somestuff::OneClass;
68 OneClass f;
69 f.//-4-
70 ; //#4# ( "aFunc" "anInt" )
71}
72
73// Dereferencing alias types created through 'using' statements
74
75// Alias with fully qualified name
76void func4()
77{
78 otherstuff::OneClass f;
79 f. //-5-
80 ; //#5# ( "aFunc" "anInt" )
81}
82
83// Alias through namespace directive
84void func5()
85{
86 using namespace otherstuff;
87 OneClass f;
88 f. //-6-
89 ; //#6# ( "aFunc" "anInt" )
90}
91
92// Check name hiding
93void func6()
94{
95 using namespace morestuff;
96 OneClass f; // Alias for somestuff::OneClass
97 f. //-7-
98 ; //#7# ( "aFunc" "anInt" )
99 aStruct g; // This however is morestuff::aStruct !
100 g. //-8-
101 ; //#8# ( "anotherBar" "anotherFoo" )
102}
103
104// Alias of an alias
105// Currently doesn't work interactively for some reason.
106void func6()
107{
108 using namespace evenmorestuff;
109 OneClass f;
110 f. //-7-
111 ; //#7# ( "aFunc" "anInt" )
112}
113
114// Alias for struct in nested namespace, fully qualified
115void func7()
116{
117 outer::StructNested f;
118 f.//-8-
119 ; //#8# ( "one" "two" )
120}
121
122// Alias for nested namespace
123void func8()
124{
125 using namespace outerinner;
126 StructNested f;
127 AnotherStruct g;
128 f.//-9-
129 ; //#9# ( "one" "two" )
130 g.//-10-
131 ; //#10# ( "four" "three" )
132}
diff --git a/test/cedet/tests/testusing.hh b/test/cedet/tests/testusing.hh
new file mode 100644
index 00000000000..d8b4e905531
--- /dev/null
+++ b/test/cedet/tests/testusing.hh
@@ -0,0 +1,125 @@
1// test usings header file.
2
3namespace moose {
4
5 class Point;
6
7 class MyClass;
8
9}
10
11
12namespace moose {
13
14 class Point;
15
16 class MyClass {
17 public:
18 MyClass() : fVal(0) {
19 }
20
21 ~MyClass() {};
22
23 /**
24 * fVal Accessors
25 * @{
26 */
27 int getVal() const {
28 return fVal;
29 }
30 void setVal(int Val) const {
31 fVal = Val;
32 }
33 /**
34 * @}
35 */
36 private:
37 int fVal;
38 };
39
40}
41
42namespace deer {
43
44 class Pickle;
45
46};
47
48// Code from Zhiqiu Kong
49
50#ifndef BREAD_H
51#define BREAD_H
52
53namespace bread_name {
54 class bread
55 {
56 public:
57 void geta();
58 private:
59 int m_a;
60 int m_b;
61 };
62}
63
64#endif
65
66// Code from David Engster
67// Creating alias types through 'using' trickery
68
69namespace somestuff {
70 class OneClass {
71 public:
72 void aFunc();
73 int anInt;
74 };
75 struct aStruct {
76 int foo;
77 int bar;
78 };
79}
80
81namespace otherstuff {
82 // make otherstuff::OneClass an alias for somestuff::OneClass
83 using somestuff::OneClass;
84}
85
86namespace morestuff {
87 // make morestuff an alias namespace for somestuff
88 using namespace somestuff;
89 // but hide aStruct with own type
90 struct aStruct {
91 int anotherFoo;
92 int anotherBar;
93 };
94}
95
96// We can also create an alias for an alias
97namespace evenmorestuff {
98 using otherstuff::OneClass;
99}
100
101// Now with nested namespaces
102namespace outer {
103 namespace inner {
104 struct StructNested {
105 int one;
106 int two;
107 };
108 struct AnotherStruct {
109 int three;
110 int four;
111 };
112 }
113}
114
115// Elevate the first struct into 'outer'
116// so that we can access it via 'outer::StructNested'
117namespace outer {
118 using outer::inner::StructNested;
119}
120
121// Create an alias for a nested namespace
122namespace outerinner {
123 // equivalent to 'namespace outerinner = outer::inner;'
124 using namespace outer::inner;
125}
diff --git a/test/cedet/tests/testvarnames.c b/test/cedet/tests/testvarnames.c
new file mode 100644
index 00000000000..5e576fd0328
--- /dev/null
+++ b/test/cedet/tests/testvarnames.c
@@ -0,0 +1,71 @@
1/*
2 * Test variable and function names, lists of variables on one line, etc.
3 */
4
5struct independent {
6 int indep_1;
7 int indep_2;
8};
9
10struct independent var_indep_struct;
11
12struct {
13 int unnamed_1;
14 int unnamed_2;
15} var_unamed_struct;
16
17struct {
18 int unnamed_3;
19 int unnamed_4;
20} var_un_2, var_un_3;
21
22struct inlinestruct {
23 int named_1;
24 int named_2;
25} var_named_struct;
26
27struct inline2struct {
28 int named_3;
29 int named_4;
30} var_n_2, var_n_3;
31
32/* Structures with names that then declare variables
33 * should also be completable.
34 *
35 * Getting this to work is the bugfix in semantic-c.el CVS v 1.122
36 */
37struct inlinestruct in_var1;
38struct inline2struct in_var2;
39
40int test_1(int var_arg1) {
41
42 var_// -1-
43 ; // #1# ("var_arg1" "var_indep_struct" "var_n_2" "var_n_3" "var_named_struct" "var_un_2" "var_un_3" "var_unamed_struct")
44
45 var_indep_struct.// -2-
46 ; // #2# ( "indep_1" "indep_2" )
47
48 var_unamed_struct.// -3-
49 ; // #3# ( "unnamed_1" "unnamed_2" )
50
51 var_named_struct.// -4-
52 ; // #4# ( "named_1" "named_2" )
53
54 var_un_2.// -5-
55 ; // #5# ( "unnamed_3" "unnamed_4" )
56 var_un_3.// -6-
57 ; // #6# ( "unnamed_3" "unnamed_4" )
58
59 var_n_2.// -7-
60 ; // #7# ( "named_3" "named_4" )
61 var_n_3.// -8-
62 ; // #8# ( "named_3" "named_4" )
63
64 in_// -9-
65 ; // #9# ( "in_var1" "in_var2" )
66
67 in_var1.// -10-
68 ; // #10# ( "named_1" "named_2")
69 in_var2.// -11-
70 ; // #11# ( "named_3" "named_4")
71}