aboutsummaryrefslogtreecommitdiffstats
path: root/test/cedet/tests/test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cedet/tests/test.cpp')
-rw-r--r--test/cedet/tests/test.cpp592
1 files changed, 0 insertions, 592 deletions
diff --git a/test/cedet/tests/test.cpp b/test/cedet/tests/test.cpp
deleted file mode 100644
index 0c43944a031..00000000000
--- a/test/cedet/tests/test.cpp
+++ /dev/null
@@ -1,592 +0,0 @@
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
7/* An include test */
8#include <stdio.h>
9
10#include <cmath>
11
12#include "c++-test.hh"
13
14#include <c++-test.hh>
15
16double var1 = 1.2;
17
18int simple1(int a) {
19
20}
21
22struct foo1 {
23 int test;
24};
25
26struct foo2 : public foo1 {
27 const int foo21(int a, int b);
28 const int foo22(int a, int b) { return 1 }
29};
30
31/* Classes */
32class class1 {
33private:
34 int var11;
35 struct foo1 var12;
36public:
37 int p_var11;
38 struct foo p_var12;
39};
40
41class i_class1 : public class1 {
42private:
43 int var11;
44 struct foo var12;
45public:
46 int p_var11;
47 struct foo p_var12;
48};
49
50class class2 {
51private:
52 int var21;
53 struct foo var22;
54public:
55 int p_var21;
56 struct foo p_var22;
57};
58
59class i_class2 : public class1, public class2 {
60private:
61 int var21;
62 struct foo var22;
63protected:
64 int pt_var21;
65public:
66 int p_var21;
67 struct foo p_var22;
68};
69
70class class3 {
71 /* A class with strange things in it */
72public:
73 class3(); /* A constructor */
74 enum embedded_foo_enum {
75 a, b, c
76 } embed1;
77 struct embedded_bar_struct {
78 int a;
79 int b;
80 } embed2;
81 class embedded_baz_class {
82 embedded_baz_class();
83 ~embedded_baz_class();
84 } embed3;
85 ~class3(); /* destructor */
86
87 /* Methods */
88 int method_for_class3(int a, char b);
89
90 int inline_method(int c) { return c; }
91
92 /* Operators */
93 class3& operator^= (const class3& something);
94
95 /* Funny declmods */
96 const class3 * const method_const_ptr_ptr(const int * const argconst) const = 0;
97};
98
99class3::class3()
100{
101 /* Constructor outside the definition. */
102}
103
104int class3::method_for_class3(int a, char b)
105{
106}
107
108int class3::method1_for_class3( int a, int &b)
109{
110 int cvariablename;
111 class3 fooy[];
112 class3 moose = new class3;
113
114 // Complktion testing line should find external members.
115 a = fooy[1].me ;
116 b = cv ;
117
118 if (fooy.emb) {
119 simple1(c);
120 }
121
122 cos(10);
123 abs(10);
124
125 return 1;
126}
127
128char class3::method2_for_class3( int a, int b) throw ( exception1 )
129{
130 return 'a';
131}
132
133void *class3::method3_for_class3( int a, int b) throw ( exception1, exception2 )
134{
135 int q = a;
136 return "Moose";
137}
138
139void *class3::method31_for_class3( int a, int b) throw ( )
140{
141 int q = a;
142 return "Moose";
143}
144
145void *class3::method4_for_class3( int a, int b) reentrant
146{
147 class3 ct;
148
149 ct.method5_for_class3(1,a);
150
151 pritf();
152}
153
154/*
155 * A method on class3.
156 */
157void *class3::method5_for_class3( int a, int b) const
158{
159}
160
161/*
162 * Namespace parsing tests
163 */
164namespace NS {
165 class class_in_namespace {
166 int equiv(const NS::class_in_namespace *) const;
167 };
168}
169
170int NS::class_in_namespace::equiv(const NS::class_in_namespace *cin) const
171{
172 return 0;
173}
174
175// Stuff Klaus found.
176// Inheritance w/out a specifying for public.
177class class4 : class1 {
178 // Pure virtual methods.
179 void virtual print () const = 0;
180
181public:
182 // The whacky constructor type
183 class4()
184 try : class1(args)
185 {
186 // constructor body
187 }
188 catch ()
189 {
190
191 }
192
193
194};
195
196class class5 : public virtual class4 {
197 // Virtual inheritance
198};
199
200class class6 : class1 {
201 // Mutable
202 mutable int i;
203};
204
205/* Namespaces */
206namespace namespace1 {
207 void ns_method1() { }
208
209 class n_class1 {
210 public:
211 void method11(int a) { }
212 };
213
214 /* This shouldn't parse due to missing semicolon. */
215 class _n_class2 : public n_class1 {
216 void n_c2_method1(int a, int b) { }
217 };
218
219 // Macros in the namespace
220#define NSMACRO 1
221
222 // Template in the namespace
223 template<class T> T nsti1(const Foo& foo);
224 template<> int nsti1<int>(const Foo& foo);
225
226}
227
228namespace namespace2 {
229
230 using namespace1::n_class1;
231
232}
233
234/* Initializers */
235void tinitializers1(): inita1(False),
236 inita2(False)
237{
238 inita1= 1;
239}
240
241/* How about Extern C type things. */
242int funny_prototype(int ,int b,float c)
243{
244
245}
246
247extern "C"
248int extern_c_1(int a, int b)
249{
250
251 funny_prototype(1,2,3.4);
252
253 printf("Moose", );
254
255 return 1;
256}
257
258extern "C" {
259
260 int extern_c_2(int a, int b)
261 {
262 return 1;
263 }
264
265}
266
267// Some operator stuff
268class Action
269{
270 // Problems!! operator() and operator[] can not be parsed with semantic
271 // 1.4.2 but with latest c.by
272 virtual void operator()(int i, char *p ) = 0;
273 virtual String& operator[]() = 0;
274 virtual void operator!() = 0;
275 virtual void operator->() = 0;
276 virtual T& operator+=();
277 virtual T& operator*();
278 virtual T& operator*=();
279};
280
281// class with namespace qualified parents
282class Multiinherit : public virtual POA::Parent,
283 public virtual POA::Parent1,
284 Parent
285{
286private:
287 int i;
288
289public:
290 Multiinherit();
291 ~Multiinherit();
292
293 // method with a list of qualified exceptions
294 void* throwtest()
295 throw(Exception0,
296 Testnamespace::Exception1,
297 Testnamespace::Excpetion2,
298 Testnamespace::testnamespace1::Exception3);
299
300};
301
302void*
303Multiinherit::throwtest()
304 throw (Exception0,
305 Testnamespace::Exception1,
306 Testnamespace::Excpetion2,
307 Testnamespace::testnamespace1::Exception3)
308{
309 return;
310}
311
312// Jens Rock <jens.rock@asamnet.de>: Nested classes or structs defined
313// outside of the containing class/struct.
314class container
315{
316 public:
317 struct contained;
318 container();
319 ~container();
320};
321
322struct container::contained
323{
324 public:
325 contained();
326 ~contained();
327};
328
329/*
330 * Ok, how about some template stuff.
331 */
332template <class CT, class container = vector<CT> >
333const CT& max (const CT& a, const CT& b)
334{
335 return a < b ? b : a;
336}
337
338// Arne Schmitz found this one
339std::vector<int> &a, &b, &c;
340
341class TemplateUsingClass
342{
343 typedef TestClassMap::iterator iterator;
344 typedef map<long, long> TestClassMap;
345
346 // typedefs with const and volatile
347 typedef const map<long, long> const_TestClassMap;
348 typedef TestClassMap<string>::iterator volatile volatile_iterator;
349
350 map<int, int> mapclassvarthingy;
351};
352
353template<class T> T ti1(const Foo& foo);
354template<> int ti1<int>(const Foo& foo);
355
356
357// -----------------------------------
358// Now some namespace and related stuff
359// -----------------------------------
360
361using CORBA::LEX::get_token;
362using Namespace1;
363
364using namespace POA::std;
365using namespace Test;
366
367
368
369namespace Parser
370{
371 namespace
372 {
373 using Lexer::get_test;
374 string str = "";
375 }
376
377 namespace XXX
378 {
379
380 class Foobar : public virtual POA::Parent,
381 public virtual POA::Parent1,
382 private POA::list<fact>,
383 private map<string>
384 {
385 ini i;
386 list <shared_ptr<item> >::const_iterator l;
387 public:
388
389 Foobar();
390 ~Foobar();
391 };
392 }
393
394
395 void test_function(int i);
396
397};
398
399// unnamed namespaces - even nested
400namespace
401{
402 namespace
403 {
404 using Lexer::get_test;
405 string str = "";
406 }
407
408 // some builtin types
409 long long ll = 0;
410 long double d = 0.0;
411 unsigned test;
412 unsigned long int **uli = 0;
413 signed si = 0;
414 signed short ss = 0;
415 short int i = 0;
416 long int li = 0;
417
418 // expressions with namespace/class-qualifyiers
419 ORB_var cGlobalOrb = ORB::_nil();
420 ORB_var1 cGlobalOrb1 = ORB::_test;
421
422 class Testclass
423 {
424 #define TEST 0
425 ini i;
426
427 public:
428
429 Testclass();
430 ~Testclass();
431 };
432
433 static void test_function(unsigned int i);
434
435};
436
437
438// outside method implementations which should be grouped to type Test
439XXX&
440Test::waiting()
441{
442 return;
443}
444
445void
446Test::print()
447{
448 return;
449}
450
451// outside method implementations with namespaces which should be grouped to
452// their complete (incl. namespace) types
453void*
454Parser::XXX::Foobar::wait(int i, const char const * const * p)
455{
456 return;
457}
458
459void*
460Namespace1::Test::wait1(int i)
461{
462 return;
463}
464
465int
466Namespace1::Test::waiting(int i)
467{
468 return;
469}
470
471// a class with some outside implementations which should all be grouped to
472// this class declaration
473class ClassWithExternals
474{
475private:
476 int i;
477
478public:
479 ClassWithExternals();
480 ~ClassWithExternals();
481 void non_nil();
482};
483
484
485// Foobar is not displayed; seems that semantic tries to add this to the class
486// Foobar but can not find/display it, because contained in the namespace above.
487void
488Foobar::non_nil()
489{
490 return;
491}
492
493// are correctly grouped to the ClassWithExternals class
494void
495ClassWithExternals::non_nil()
496{
497 String s = "lödfjg dlfgkdlfkgjdl";
498 return;
499}
500
501ClassWithExternals::ClassWithExternals()
502{
503 return;
504}
505
506void
507ClassWithExternals::~ClassWithExternals()
508{
509 return;
510}
511
512
513// -------------------------------
514// Now some macro and define stuff
515// -------------------------------
516
517#define TEST 0
518#define TEST1 "String"
519
520// The first backslash makes this macro unmatched syntax with semantic 1.4.2!
521// With flexing \+newline as nothing all is working fine!
522#define MZK_ENTER(METHOD) \
523{ \
524 CzkMethodLog lMethodLog(METHOD,"Framework");\
525}
526
527#define ZK_ASSERTM(METHOD,ASSERTION,MESSAGE) \
528 { if(!(ASSERTION))\
529 {\
530 std::ostringstream lMesgStream; \
531 lMesgStream << "Assertion failed: " \
532 << MESSAGE; \
533 CzkLogManager::doLog(CzkLogManager::FATAL,"",METHOD, \
534 "Assert",lMesgStream); \
535 assert(ASSERTION);\
536 }\
537 }
538
539// Test if not newline-backslashes are handled correctly
540string s = "My \"quoted\" string";
541
542// parsed fine as macro
543#define FOO (arg) method(arg, "foo");
544
545// With semantic 1.4.2 this parsed as macro BAR *and* function method.
546// With latest c.bnf at least one-liner macros can be parsed correctly.
547#define BAR (arg) CzkMessageLog method(arg, "bar");
548
549// some const and volatile stuff
550char * p1 = "Hello"; // 1. variable Pointer, variable Data
551const char * p2 = "Hello"; // 2. variable pointer, constant data
552char * const p3 = "Hello"; // 3. constant pointer, variable data
553const char * const p4 = "Hello"; // 4. constant pointer, constant data
554
555// Case 2 and 4 can exchange first "const" and "char"
556char const * p21 = "Hello"; // variable pointer, constant data
557char const * const p41 = "Hello"; // constant pointer, constant data
558
559char volatile a = 0; // a volatile char
560void foo(bar const &arg); // a reference to a const bar
561int foobar(bar const * const p); // a const pointer to a const bar
562int foobar(bar const volatile * const p); // a const pointer to a const bar
563int foobar3(char* p); // a const pointer to a const bar
564
565// Should not be parsed because this is invalid code
566int const & const r3 = i;
567
568boolean i = 0;
569boolean & r1 = i;
570boolean const & r2 = i;
571
572// const * sequences can be very long in C++ ;-)
573char const * const * const * const * ppp;
574
575// complex function declarationen with named pointer-arguments
576const char** foobar1(volatile char const * const **p);
577const char** foobar11(volatile Test::Namespace::Char<char*> const * const **p);
578
579// complex function declarationen with unnamed pointer-arguments
580const char* foobar2(const char***);
581const char* foobar21(const Test::Namespace::Char<char>***);
582
583// string literal parsing even with wchar_t
584char const *p = "string1";
585char const *q = "string1" "str\"ing2" "string3";
586wchar_t testc = L'a';
587
588wchar_t const *wp = L"string with a \" in it";
589wchar_t const *wq = L"string \n\t\"test" L"string2";
590wchar_t const *wr = L"string L";
591
592// arch-tag: 59828880-d72f-4059-922f-89579edf9e58