diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2009-09-28 23:23:31 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2009-09-28 23:23:31 +0000 |
commit | 74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a (patch) | |
tree | d895d7e93cf93022f48bd6d173f616f1bb4b99fc /test/cedet/tests | |
parent | b9de0a4665563f847bc7c94f8c89180bf2a9f6bd (diff) | |
download | emacs-74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a.tar.gz |
Add CEDET tests.
Diffstat (limited to 'test/cedet/tests')
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 @@ +/* Test scoping rules for c++ in the analyzer. */ + +namespace { + + class aclass2; // Forward reference. + + class aclass1 { + private: + int attrp1; + int amethodp1(int argp1); + aclass2 areference; + protected: + int attrpr1; + public: + int attr1; + int amethod1(int arg1); + }; +} + +namespace { + class aclass2 : public aclass1 + { + private: + int attrp2; + int amethodp2(int argp1); + public: + aclass2(int aninitvalue); + ~aclass2(); + int attr2; + int amethod2(int arg2); + }; +} + +aclass2::aclass2(init aninitvalue) +{ + /* This is a comment that talks about aclass1 */ + aclass1; +} + +int aclass2::amethod2(int arg2) +{ + int alocalvar; + float q; + + ac; +} + 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 @@ +class Foo { + + public void a1() {} + + class Bar { + + public int a2() {} + + public void b() { + a // -1- + } + + class Baz { + + public int a3() {} + + public Baz(int a4) { + a // -2- + } + + } + + } + +}
\ 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 @@ +// C++ examples and requests from Klaus Berndl + +// template in a unnamed namespace +namespace +{ + template<typename Target, typename Source> + Target lexical_cast(Source arg) + { + std::stringstream interpreter; + Target result; + + if(!(interpreter << arg) || !(interpreter >> result) || + !(interpreter >> std::ws).eof()) + throw bad_lexical_cast(); + + return result; + } +} + + +template <class T, FOO> class Vector +{ +private: + static T* v; + int sz; + +public: + T& elem(int i) {return v[i];} + virtual ~Vector (); + +protected: + Vector (); +}; + +template <> class Vector <void*> +{ +private: + void** v; + int sz; + +public: + Vector (); + virtual int func1(int i); + virtual int func2(int i) = 0; + static virtual int func3(int i) = 0; + void*& elem(int i) {return v[i];} + //... +}; + +// template contains namespace +typedef vector<CzkUtilities::Action*> ActionList; + +// declaration of some template-types +map<XXX, Test::YYY>** map_var; + +map_with_size<XXX, Test::YYY, size> map_size_var; +typedef map_with_size<XXX, Test::YYY, size> SizedMap; + +map_with_10_size<XXX, Test::YYY, 10>* pMap_size10_var; +typedef map_with_10_size<XXX, Test::YYY, 10> Size10Map; + +// a function which such a template-argument +void* test_function(map<ClassX, Test::ClassY, 10>* pMap); + + +template <class T> class Vector <T*> : private Vector <void*> +{ +public: + typedef Vector <void*> Base; + + Vector () : Base() {} + + T*& elem(int i) {return static_cast<T*&>(Base::elem(i));} + //... +}; + +// outside method implementation of a template-class +template<class T> T& Vector<T*>::elem(int i) +{ + return C; +} + +// same but qualified with a namespace Testnamespace +template<class T> T& Testnamespace::Vector<T*>::elem(int i) +{ + return C; +} + +// function templates with keyword typename +template<typename Target, typename Source> +Target lexical_cast(Source arg) +{ + std::stringstream interpreter; + Target result; + + if(!(interpreter << arg) || !(interpreter >> result) || + !(interpreter >> std::ws).eof()) + throw bad_lexical_cast(); + + return result; +} + +template<class T> +static +typename T::_ptr_type +getService(const std::string& pServiceName, const int pRetries=20) +{ + return T::_narrow(getServiceObject(pServiceName, pRetries)); +} + +// function template declaration +template<class T> void sort(vector<T>&); +// complex function template definition +template<class T, class S, const NamespaceY::ClassX<TestClass, &s> volatile ***&i> +map<ClassY, ClassX, 10> +sort(const vector<T>& v) +{ + return; +} + +// variable declarations of template-types +foo<TClass, Testnamespace::XClass, i> *bar1; +foo<TClass, Testnamespace::XClass, **&i> *bar2; +foo<TClass, Testnamespace::XClass, *Namespace::ClassX::i> bar3; +foo<0> bar0; + +class SomeName; +class OtherName; + diff --git a/test/cedet/tests/test.c b/test/cedet/tests/test.c new file mode 100644 index 00000000000..3146bbcc53a --- /dev/null +++ b/test/cedet/tests/test.c @@ -0,0 +1,222 @@ +/* Test file for C language. + * Attempt to include as many aspects of the C language as possible. + * + * $Id: test.c,v 1.1.2.1 2009/09/20 04:00:17 cyd Exp $ + * + */ +/* types of include files */ +#include "includeme1.h" +#include <includeme2.h> +#include <subdir/includeme3.h> +#include <includeme.notanhfile> +#include <stdlib.h> +#include <cmath> + +#if 0 +int dont_show_function() +{ +} +#endif + +/* Global types */ +struct mystruct1 { + int slot11; + char slot12; + float slot13; +}; + +struct mystruct2 { + int slot21; + char slot22; + float slot23; +} var_of_type_mystruct2; + +struct { + int slot31; + char slot32; + float slot33; +} var_of_anonymous_struct; + +typedef struct mystruct1 typedef_of_mystruct1; +typedef struct mystruct1 *typedef_of_pointer_mystruct1; +typedef struct { int slot_a; } typedef_of_anonymous_struct; +typedef struct A { +} B; + +typedef struct mystruct1 td1, td2; + +union myunion1 { + int slot41; + char slot42; + float slot43; +}; + +union myunion2 { + int slot51; + char slot52; + float slot53; +} var_of_type_myunion2; + +struct { + int slot61; + char slot72; + float slot83; +} var_of_anonymous_union; + +typedef union myunion1 typedef_of_myunion1; +typedef union myunion1 *typedef_of_pointer_myunion1; +typedef union { int slot_a; } typedef_of_anonymous_union; + +enum myenum1 { enum11 = 1, enum12 }; +enum myenum2 { enum21, enum22 = 2 } var_of_type_myenum2; +enum { enum31, enum32 } var_of_anonymous_enum; + +typedef enum myenum1 typedef_of_myenum1; +typedef enum myenum1 *typedef_of_pointer_myenum1; +typedef enum { enum_a = 3, enum_b } typedef_of_anonymous_enum; + +typedef int typedef_of_int; + +/* Here are some simpler variable types */ +int var1; +int varbit1:1; +char var2; +float var3; +mystruct1 var3; +struct mystruct1 var4; +union myunion1 var5; +enum myenum1 var6; + +char *varp1; +char **varp2; +char varv1[1]; +char varv2[1][2]; + +char *varpa1 = "moose"; +struct mystruct2 vara2 = { 1, 'a', 0.0 }; +enum myenum1 vara3 = enum11; +int vara4 = (int)0.0; +int vara5 = funcall(); + +int mvar1, mvar2, mvar3; +char *mvarp1, *mvarp2, *mvarp3; +char *mvarpa1 = 'a', *mvarpa2 = 'b', *mvarpa3 = 'c'; +char mvaras1[10], mvaras2[12][13], *mvaras3 = 'd'; + +static register const unsigned int tmvar1; + +#define MACRO1 1 +#define MACRO2(foo) (1+foo) + +/* Here are some function prototypes */ + +/* This is legal, but I decided not to support inferred integer + * types on functions and variables. + */ +fun0(); +int funp1(); +char funp2(int arg11); +float funp3(char arg21, char arg22); +struct mystrct1 funp4(struct mystruct2 arg31, union myunion2 arg32); +enum myenum1 funp5(char *arg41, union myunion1 *arg42); + +char funpp1 __P(char argp1, struct mystruct2 argp2, char *arg4p); + +int fun1(); + +/* Here is a function pointer */ +int (*funcptr)(int a, int b); + +/* Function Definitions */ + +/* This is legal, but I decided not to support inferred integer + * types on functions and variables. + */ +fun0() +{ + int sv = 0; +} + +int fun1 () +{ + int sv = 1; +} + +int fun1p1 (void) +{ + int sv = 1; +} + +char fun2(int arg_11) +{ + char sv = 2; +} + +float fun3(char arg_21, char arg_22) +{ + char sv = 3; +} + +struct mystrct1 fun4(struct mystruct2 arg31, union myunion2 arg32) +{ + sv = 4; +} + +enum myenum1 fun5(char *arg41, union myunion1 *arg42) +{ + sv = 5; +} + +/* Functions with K&R syntax. */ +struct mystrct1 funk1(arg_31, arg_32) + struct mystruct2 arg_31; + union myunion2 arg32; +{ + sv = 4; +} + +enum myenum1 *funk2(arg_41, arg_42) + char *arg_41; + union myunion1 *arg_42; +{ + sv = 5; + + if(foo) { + } +} + +int funk3(arg_51, arg_53) + int arg_51; + char arg_53; +{ + char q = 'a'; + int sv = 6; + td1 ms1; + enum myenum1 testconst; + + /* Function argument analysis */ + funk3(ms1.slot11, arg_53 ); + sv = 7; + + /* Slot deref on assignee */ + ms1.slot11 = s; + + /* Enum/const completion */ + testconst = e; + + /* Bad var/slot and param */ + blah.notafunction(moose); + + /* Print something. */ + printf("Moose", ); + + tan(); +} + +int funk4_fixme(arg_61, arg_62) + int arg_61, arg_62; +{ + +} + +/* End of C tests */ diff --git a/test/cedet/tests/test.cpp b/test/cedet/tests/test.cpp new file mode 100644 index 00000000000..43887b084a1 --- /dev/null +++ b/test/cedet/tests/test.cpp @@ -0,0 +1,593 @@ +/* Test file for C++ language. + * Attempt to include as many aspects of the C++ language as possible. + * Do not include things tested in test.c since that shares the + * same language. + * + * $Id: test.cpp,v 1.1.2.1 2009/09/20 04:00:17 cyd Exp $ + * + */ + +/* An include test */ +#include <stdio.h> + +#include <cmath> + +#include "c++-test.hh" + +#include <c++-test.hh> + +double var1 = 1.2; + +int simple1(int a) { + +} + +struct foo1 { + int test; +}; + +struct foo2 : public foo1 { + const int foo21(int a, int b); + const int foo22(int a, int b) { return 1 } +}; + +/* Classes */ +class class1 { +private: + int var11; + struct foo1 var12; +public: + int p_var11; + struct foo p_var12; +}; + +class i_class1 : public class1 { +private: + int var11; + struct foo var12; +public: + int p_var11; + struct foo p_var12; +}; + +class class2 { +private: + int var21; + struct foo var22; +public: + int p_var21; + struct foo p_var22; +}; + +class i_class2 : public class1, public class2 { +private: + int var21; + struct foo var22; +protected: + int pt_var21; +public: + int p_var21; + struct foo p_var22; +}; + +class class3 { + /* A class with strange things in it */ +public: + class3(); /* A constructor */ + enum embedded_foo_enum { + a, b, c + } embed1; + struct embedded_bar_struct { + int a; + int b; + } embed2; + class embedded_baz_class { + embedded_baz_class(); + ~embedded_baz_class(); + } embed3; + ~class3(); /* destructor */ + + /* Methods */ + int method_for_class3(int a, char b); + + int inline_method(int c) { return c; } + + /* Operators */ + class3& operator^= (const class3& something); + + /* Funny declmods */ + const class3 * const method_const_ptr_ptr(const int * const argconst) const = 0; +}; + +class3::class3() +{ + /* Constructor outside the definition. */ +} + +int class3::method_for_class3(int a, char b) +{ +} + +int class3::method1_for_class3( int a, int &b) +{ + int cvariablename; + class3 fooy[]; + class3 moose = new class3; + + // Complktion testing line should find external members. + a = fooy[1].me ; + b = cv ; + + if (fooy.emb) { + simple1(c); + } + + cos(10); + abs(10); + + return 1; +} + +char class3::method2_for_class3( int a, int b) throw ( exception1 ) +{ + return 'a'; +} + +void *class3::method3_for_class3( int a, int b) throw ( exception1, exception2 ) +{ + int q = a; + return "Moose"; +} + +void *class3::method31_for_class3( int a, int b) throw ( ) +{ + int q = a; + return "Moose"; +} + +void *class3::method4_for_class3( int a, int b) reentrant +{ + class3 ct; + + ct.method5_for_class3(1,a); + + pritf(); +} + +/* + * A method on class3. + */ +void *class3::method5_for_class3( int a, int b) const +{ +} + +/* + * Namespace parsing tests + */ +namespace NS { + class class_in_namespace { + int equiv(const NS::class_in_namespace *) const; + }; +} + +int NS::class_in_namespace::equiv(const NS::class_in_namespace *cin) const +{ + return 0; +} + +// Stuff Klaus found. +// Inheritance w/out a specifying for public. +class class4 : class1 { + // Pure virtual methods. + void virtual print () const = 0; + +public: + // The whacky constructor type + class4() + try : class1(args) + { + // constructor body + } + catch () + { + + } + + +}; + +class class5 : public virtual class4 { + // Virtual inheritance +}; + +class class6 : class1 { + // Mutable + mutable int i; +}; + +/* Namespaces */ +namespace namespace1 { + void ns_method1() { } + + class n_class1 { + public: + void method11(int a) { } + }; + + /* This shouldn't parse due to missing semicolon. */ + class _n_class2 : public n_class1 { + void n_c2_method1(int a, int b) { } + }; + + // Macros in the namespace +#define NSMACRO 1 + + // Template in the namespace + template<class T> T nsti1(const Foo& foo); + template<> int nsti1<int>(const Foo& foo); + +} + +namespace namespace2 { + + using namespace1::n_class1; + +} + +/* Initializers */ +void tinitializers1(): inita1(False), + inita2(False) +{ + inita1= 1; +} + +/* How about Extern C type things. */ +int funny_prototype(int ,int b,float c) +{ + +} + +extern "C" +int extern_c_1(int a, int b) +{ + + funny_prototype(1,2,3.4); + + printf("Moose", ); + + return 1; +} + +extern "C" { + + int extern_c_2(int a, int b) + { + return 1; + } + +} + +// Some operator stuff +class Action +{ + // Problems!! operator() and operator[] can not be parsed with semantic + // 1.4.2 but with latest c.by + virtual void operator()(int i, char *p ) = 0; + virtual String& operator[]() = 0; + virtual void operator!() = 0; + virtual void operator->() = 0; + virtual T& operator+=(); + virtual T& operator*(); + virtual T& operator*=(); +}; + +// class with namespace qualified parents +class Multiinherit : public virtual POA::Parent, + public virtual POA::Parent1, + Parent +{ +private: + int i; + +public: + Multiinherit(); + ~Multiinherit(); + + // method with a list of qualified exceptions + void* throwtest() + throw(Exception0, + Testnamespace::Exception1, + Testnamespace::Excpetion2, + Testnamespace::testnamespace1::Exception3); + +}; + +void* +Multiinherit::throwtest() + throw (Exception0, + Testnamespace::Exception1, + Testnamespace::Excpetion2, + Testnamespace::testnamespace1::Exception3) +{ + return; +} + +// Jens Rock <jens.rock@asamnet.de>: Nested classes or structs defined +// outside of the containing class/struct. +class container +{ + public: + struct contained; + container(); + ~container(); +}; + +struct container::contained +{ + public: + contained(); + ~contained(); +}; + +/* + * Ok, how about some template stuff. + */ +template <class CT, class container = vector<CT> > +const CT& max (const CT& a, const CT& b) +{ + return a < b ? b : a; +} + +// Arne Schmitz found this one +std::vector<int> &a, &b, &c; + +class TemplateUsingClass +{ + typedef TestClassMap::iterator iterator; + typedef map<long, long> TestClassMap; + + // typedefs with const and volatile + typedef const map<long, long> const_TestClassMap; + typedef TestClassMap<string>::iterator volatile volatile_iterator; + + map<int, int> mapclassvarthingy; +}; + +template<class T> T ti1(const Foo& foo); +template<> int ti1<int>(const Foo& foo); + + +// ----------------------------------- +// Now some namespace and related stuff +// ----------------------------------- + +using CORBA::LEX::get_token; +using Namespace1; + +using namespace POA::std; +using namespace Test; + + + +namespace Parser +{ + namespace + { + using Lexer::get_test; + string str = ""; + } + + namespace XXX + { + + class Foobar : public virtual POA::Parent, + public virtual POA::Parent1, + private POA::list<fact>, + private map<string> + { + ini i; + list <shared_ptr<item> >::const_iterator l; + public: + + Foobar(); + ~Foobar(); + }; + } + + + void test_function(int i); + +}; + +// unnamed namespaces - even nested +namespace +{ + namespace + { + using Lexer::get_test; + string str = ""; + } + + // some builtin types + long long ll = 0; + long double d = 0.0; + unsigned test; + unsigned long int **uli = 0; + signed si = 0; + signed short ss = 0; + short int i = 0; + long int li = 0; + + // expressions with namespace/class-qualifyiers + ORB_var cGlobalOrb = ORB::_nil(); + ORB_var1 cGlobalOrb1 = ORB::_test; + + class Testclass + { + #define TEST 0 + ini i; + + public: + + Testclass(); + ~Testclass(); + }; + + static void test_function(unsigned int i); + +}; + + +// outside method implementations which should be grouped to type Test +XXX& +Test::waiting() +{ + return; +} + +void +Test::print() +{ + return; +} + +// outside method implementations with namespaces which should be grouped to +// their complete (incl. namespace) types +void* +Parser::XXX::Foobar::wait(int i, const char const * const * p) +{ + return; +} + +void* +Namespace1::Test::wait1(int i) +{ + return; +} + +int +Namespace1::Test::waiting(int i) +{ + return; +} + +// a class with some outside implementations which should all be grouped to +// this class declaration +class ClassWithExternals +{ +private: + int i; + +public: + ClassWithExternals(); + ~ClassWithExternals(); + void non_nil(); +}; + + +// Foobar is not displayed; seems that semantic tries to add this to the class +// Foobar but can not find/display it, because contained in the namespace above. +void +Foobar::non_nil() +{ + return; +} + +// are correctly grouped to the ClassWithExternals class +void +ClassWithExternals::non_nil() +{ + String s = "lödfjg dlfgkdlfkgjdl"; + return; +} + +ClassWithExternals::ClassWithExternals() +{ + return; +} + +void +ClassWithExternals::~ClassWithExternals() +{ + return; +} + + +// ------------------------------- +// Now some macro and define stuff +// ------------------------------- + +#define TEST 0 +#define TEST1 "String" + +// The first backslash makes this macro unmatched syntax with semantic 1.4.2! +// With flexing \+newline as nothing all is working fine! +#define MZK_ENTER(METHOD) \ +{ \ + CzkMethodLog lMethodLog(METHOD,"Framework");\ +} + +#define ZK_ASSERTM(METHOD,ASSERTION,MESSAGE) \ + { if(!(ASSERTION))\ + {\ + std::ostringstream lMesgStream; \ + lMesgStream << "Assertion failed: " \ + << MESSAGE; \ + CzkLogManager::doLog(CzkLogManager::FATAL,"",METHOD, \ + "Assert",lMesgStream); \ + assert(ASSERTION);\ + }\ + } + +// Test if not newline-backslashes are handled correctly +string s = "My \"quoted\" string"; + +// parsed fine as macro +#define FOO (arg) method(arg, "foo"); + +// With semantic 1.4.2 this parsed as macro BAR *and* function method. +// With latest c.bnf at least one-liner macros can be parsed correctly. +#define BAR (arg) CzkMessageLog method(arg, "bar"); + +// some const and volatile stuff +char * p1 = "Hello"; // 1. variable Pointer, variable Data +const char * p2 = "Hello"; // 2. variable pointer, constant data +char * const p3 = "Hello"; // 3. constant pointer, variable data +const char * const p4 = "Hello"; // 4. constant pointer, constant data + +// Case 2 and 4 can exchange first "const" and "char" +char const * p21 = "Hello"; // variable pointer, constant data +char const * const p41 = "Hello"; // constant pointer, constant data + +char volatile a = 0; // a volatile char +void foo(bar const &arg); // a reference to a const bar +int foobar(bar const * const p); // a const pointer to a const bar +int foobar(bar const volatile * const p); // a const pointer to a const bar +int foobar3(char* p); // a const pointer to a const bar + +// Should not be parsed because this is invalid code +int const & const r3 = i; + +boolean i = 0; +boolean & r1 = i; +boolean const & r2 = i; + +// const * sequences can be very long in C++ ;-) +char const * const * const * const * ppp; + +// complex function declarationen with named pointer-arguments +const char** foobar1(volatile char const * const **p); +const char** foobar11(volatile Test::Namespace::Char<char*> const * const **p); + +// complex function declarationen with unnamed pointer-arguments +const char* foobar2(const char***); +const char* foobar21(const Test::Namespace::Char<char>***); + +// string literal parsing even with wchar_t +char const *p = "string1"; +char const *q = "string1" "str\"ing2" "string3"; +wchar_t testc = L'a'; + +wchar_t const *wp = L"string with a \" in it"; +wchar_t const *wq = L"string \n\t\"test" L"string2"; +wchar_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 @@ +;; Test file for Emacs Lisp. +;; Attempt to include as many aspects of Emacs Lisp as possible. +;; + +;;; Require +;; +(require 'semantic) +(require 'eieio "../eieio") + +;; tags encapsulated in eval-when-compile and eval-and-compile +;; should be expanded out into the outer environment. +(eval-when-compile + (require 'semantic-imenu) + ) + +(eval-and-compile + (defconst const-1 nil) + (defun function-1 (arg) + nil) + ) + +;;; Functions +;; +(defun a-defun (arg1 arg2 &optional arg3) + "doc a" + nil) + +(defun a-defun-interactive (arg1 arg2 &optional arg3) + "doc a that is a command" + (interactive "R") + nil) + +(defun* a-defun* (arg1 arg2 &optional arg3) + "doc a*" + nil) + +(defsubst a-defsubst (arg1 arg2 &optional arg3) + "doc a-subst" + nil) + +(defmacro a-defmacro (arg1 arg2 &optional arg3) + "doc a-macro" + nil) + +(define-overload a-overload (arg) + "doc a-overload" + nil) + +;;; Methods +;; +(defmethod a-method ((obj some-class) &optional arg2) + "Doc String for a method." + (call-next-method)) + +(defgeneric a-generic (arg1 arg2) + "General description of a-generic.") + +;;; Advice +;; +(defadvice existing-function-to-advise (around test activate) + "Do something special to this fcn." + (ad-do-it)) + +;;; Variables +;; +(defvar a-defvar (cons 1 2) + "Variable a") + +(defvar a-defvar-star (cons 1 2) + "*User visible var a") + +(defconst a-defconst 'a "var doc const") + +(defcustom a-defcustom nil + "*doc custom" + :group 'a-defgroup + :type 'boolean) + +(defface a-defface 'bold + "A face that is bold.") + +(defimage ezimage-page-minus + ((:type xpm :file "page-minus.xpm" :ascent center)) + "Image used for open files with stuff in them.") + +;;; Autoloads +;; +(autoload (quote a-autoload) "somefile" + "Non-interactive autoload." nil nil) + +(autoload (quote a-autoload-interactive) "somefile" +"Interactive autoload." t nil) + + +(defgroup a-defgroup nil + "Group for `emacs-lisp' regression-test") + +;;; Classes +;; +(defclass a-class (a-parent) + ((slot-1) + (slot-2 :initarg :slot-2) + (slot-3 :documentation "Doc about slot3") + (slot-4 :type 'boolean) + ) + "Doc String for class.") + +(defclass a-class-abstract () + nil + "Doc string for abstract class." + :abstract t) + +;;; Structures +;; +(defstruct (test-struct-1 :test 'equal) + (slot-1 :equal 'eq) + slot-2) + +(defstruct test-struct-2 + slot-1 + slot-2) + +;;; Semantic specific macros +;; +(define-lex a-lexer + "Doc String" + this + that) + +(define-mode-local-override a-overriden-function + emacs-lisp-mode (tag) + "A function that is overloaded." + nil) + +(defvar-mode-local emacs-lisp-mode a-mode-local-def + "some value") + + +;;; Provide +;; +(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 @@ +# Test makefile -*- makefile -*- + +top= +ede_FILES=Project.ede Makefile + +example_MISC=semantic-skel.el skeleton.bnf +init_LISP=semantic-load.el +DISTDIR=$(top)semantic-$(VERSION) + +# really goofy & variables tabs +A= B +A =B +A=B C +A=B\ + C + +A= http://${B} \ + ftp://${B} +B= test + +all: example semantic Languages tools senator semantic.info + +test ${B}: foo bar + @echo ${A} + +example: + @ + +init: $(init_LISP) + @echo "(add-to-list 'load-path nil)" > $@-compile-script + @if test ! -z "${LOADPATH}" ; then\ + for loadpath in ${LOADPATH}; do \ + echo "(add-to-list 'load-path \"$$loadpath\")" >> $@-compile-script; \ + done;\ + fi + @echo "(setq debug-on-error t)" >> $@-compile-script + $(EMACS) -batch -l $@-compile-script -f batch-byte-compile $^ + +include tesset.mk tusset.mk +include oneset.mk + +ifdef SOME_SYMBOL + VAR1 = foo +else + VAR1 = bar +endif + +ifndef SOME_OTHER_SYMBOL + VAR1 = baz +endif + +ifeq ($(VAR1), foo) + VAR2 = gleep +else + ifneq ($(VAR1), foo) + VAR2 = glop + endif +endif + +# End of Makefile diff --git a/test/cedet/tests/test.py b/test/cedet/tests/test.py new file mode 100644 index 00000000000..1ae5b79e7fb --- /dev/null +++ b/test/cedet/tests/test.py @@ -0,0 +1,579 @@ +# Test file for Python language. +# +# $Id: test.py,v 1.1.2.1 2009/09/20 04:00:17 cyd Exp $ + +# Simle class compount statement with blank lines sprinkled. +class Foo(Bar): + + x = 1 + + y = 2 + +# Simple def statement with no argument +def sss(): + i = 1 + +# Simple def statement with arguments +def ttt(x,y,z): + i = 1 + +import foo + +for x in y: + print x + +while y > 0: + y = y - 1 + +a=b=c=d=e=f=i=j=k=l=m=n=o=p=q=r=s=t=x=y=1 + +if x: + x = 2 + y = 3 + +x = 2 +y = 3 +s and t +q | r +o ^ p +m & n +k << l +z = 4 +i >> j +e / f +c * d +a + b +2 ** 5 +x +s = "a" "b" "c" +1 + +# implicit continuation lines, see +# http://docs.python.org/ref/implicit-joining.html + +a_list = [ 1, 2, 3, + 4, 5, + 6 ] + +a_tuple = (1, 2, 3, + + 4, 5, 6) + +a_hash = { 'a':1, "b":2, + 'c' : 3, + "d" : 4 } + + +def longarglist(a, + b, + c, + d): + a=1; + b=1; + c=1; + d=1; + +class longclasslist(xx.yyy, + zz.aa): + foo=1 + + +# wisent-python.wy chokes on this! -ryk 6/17/02 + +class HTTPServer(xxx.yyy): + allow_reuse_address = 1 # Seems to make sense in testing environment + def server_bind(self): + SocketServer.TCPServer.server_bind(self) + host, port = self.socket.getsockname() + self.server_name = socket.getfqdn(host) + self.server_port = port + + +######################################################################### +### /usr/lib/python2.2/BaseHTTPServer.py +######################################################################### + +"""HTTP server base class. + +Note: the class in this module doesn't implement any HTTP request; see +SimpleHTTPServer for simple implementations of GET, HEAD and POST +(including CGI scripts). + +Contents: + +- BaseHTTPRequestHandler: HTTP request handler base class +- test: test function + +XXX To do: + +- send server version +- log requests even later (to capture byte count) +- log user-agent header and other interesting goodies +- send error log to separate file +- are request names really case sensitive? + +""" + + +# See also: +# +# HTTP Working Group T. Berners-Lee +# INTERNET-DRAFT R. T. Fielding +# <draft-ietf-http-v10-spec-00.txt> H. Frystyk Nielsen +# Expires September 8, 1995 March 8, 1995 +# +# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt + + +# Log files +# --------- +# +# Here's a quote from the NCSA httpd docs about log file format. +# +# | The logfile format is as follows. Each line consists of: +# | +# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb +# | +# | host: Either the DNS name or the IP number of the remote client +# | rfc931: Any information returned by identd for this person, +# | - otherwise. +# | authuser: If user sent a userid for authentication, the user name, +# | - otherwise. +# | DD: Day +# | Mon: Month (calendar name) +# | YYYY: Year +# | hh: hour (24-hour format, the machine's timezone) +# | mm: minutes +# | ss: seconds +# | request: The first line of the HTTP request as sent by the client. +# | ddd: the status code returned by the server, - if not available. +# | bbbb: the total number of bytes sent, +# | *not including the HTTP/1.0 header*, - if not available +# | +# | You can determine the name of the file accessed through request. +# +# (Actually, the latter is only true if you know the server configuration +# at the time the request was made!) + + +__version__ = "0.2" + +__all__ = ["HTTPServer", "BaseHTTPRequestHandler"] + +import sys +import time +import socket # For gethostbyaddr() +import mimetools +import SocketServer + +# Default error message +DEFAULT_ERROR_MESSAGE = """\ +<head> +<title>Error response</title> +</head> +<body> +<h1>Error response</h1> +<p>Error code %(code)d. +<p>Message: %(message)s. +<p>Error code explanation: %(code)s = %(explain)s. +</body> +""" + + +class HTTPServer(SocketServer.TCPServer): + + allow_reuse_address = 1 # Seems to make sense in testing environment + + def server_bind(self): + """Override server_bind to store the server name.""" + SocketServer.TCPServer.server_bind(self) + host, port = self.socket.getsockname() + self.server_name = socket.getfqdn(host) + self.server_port = port + + +class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): + + """HTTP request handler base class. + + The following explanation of HTTP serves to guide you through the + code as well as to expose any misunderstandings I may have about + HTTP (so you don't need to read the code to figure out I'm wrong + :-). + + HTTP (HyperText Transfer Protocol) is an extensible protocol on + top of a reliable stream transport (e.g. TCP/IP). The protocol + recognizes three parts to a request: + + 1. One line identifying the request type and path + 2. An optional set of RFC-822-style headers + 3. An optional data part + + The headers and data are separated by a blank line. + + The first line of the request has the form + + <command> <path> <version> + + where <command> is a (case-sensitive) keyword such as GET or POST, + <path> is a string containing path information for the request, + and <version> should be the string "HTTP/1.0". <path> is encoded + using the URL encoding scheme (using %xx to signify the ASCII + character with hex code xx). + + The protocol is vague about whether lines are separated by LF + characters or by CRLF pairs -- for compatibility with the widest + range of clients, both should be accepted. Similarly, whitespace + in the request line should be treated sensibly (allowing multiple + spaces between components and allowing trailing whitespace). + + Similarly, for output, lines ought to be separated by CRLF pairs + but most clients grok LF characters just fine. + + If the first line of the request has the form + + <command> <path> + + (i.e. <version> is left out) then this is assumed to be an HTTP + 0.9 request; this form has no optional headers and data part and + the reply consists of just the data. + + The reply form of the HTTP 1.0 protocol again has three parts: + + 1. One line giving the response code + 2. An optional set of RFC-822-style headers + 3. The data + + Again, the headers and data are separated by a blank line. + + The response code line has the form + + <version> <responsecode> <responsestring> + + where <version> is the protocol version (always "HTTP/1.0"), + <responsecode> is a 3-digit response code indicating success or + failure of the request, and <responsestring> is an optional + human-readable string explaining what the response code means. + + This server parses the request and the headers, and then calls a + function specific to the request type (<command>). Specifically, + a request SPAM will be handled by a method do_SPAM(). If no + such method exists the server sends an error response to the + client. If it exists, it is called with no arguments: + + do_SPAM() + + Note that the request name is case sensitive (i.e. SPAM and spam + are different requests). + + The various request details are stored in instance variables: + + - client_address is the client IP address in the form (host, + port); + + - command, path and version are the broken-down request line; + + - headers is an instance of mimetools.Message (or a derived + class) containing the header information; + + - rfile is a file object open for reading positioned at the + start of the optional input data part; + + - wfile is a file object open for writing. + + IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING! + + The first thing to be written must be the response line. Then + follow 0 or more header lines, then a blank line, and then the + actual data (if any). The meaning of the header lines depends on + the command executed by the server; in most cases, when data is + returned, there should be at least one header line of the form + + Content-type: <type>/<subtype> + + where <type> and <subtype> should be registered MIME types, + e.g. "text/html" or "text/plain". + + """ + + # The Python system version, truncated to its first component. + sys_version = "Python/" + sys.version.split()[0] + + # The server software version. You may want to override this. + # The format is multiple whitespace-separated strings, + # where each string is of the form name[/version]. + server_version = "BaseHTTP/" + __version__ + + def parse_request(self): + """Parse a request (internal). + + The request should be stored in self.raw_request; the results + are in self.command, self.path, self.request_version and + self.headers. + + Return value is 1 for success, 0 for failure; on failure, an + error is sent back. + + """ + self.request_version = version = "HTTP/0.9" # Default + requestline = self.raw_requestline + if requestline[-2:] == '\r\n': + requestline = requestline[:-2] + elif requestline[-1:] == '\n': + requestline = requestline[:-1] + self.requestline = requestline + words = requestline.split() + if len(words) == 3: + [command, path, version] = words + if version[:5] != 'HTTP/': + self.send_error(400, "Bad request version (%s)" % `version`) + return 0 + elif len(words) == 2: + [command, path] = words + if command != 'GET': + self.send_error(400, + "Bad HTTP/0.9 request type (%s)" % `command`) + return 0 + else: + self.send_error(400, "Bad request syntax (%s)" % `requestline`) + return 0 + self.command, self.path, self.request_version = command, path, version + self.headers = self.MessageClass(self.rfile, 0) + return 1 + + def handle(self): + """Handle a single HTTP request. + + You normally don't need to override this method; see the class + __doc__ string for information on how to handle specific HTTP + commands such as GET and POST. + + """ + + self.raw_requestline = self.rfile.readline() + if not self.parse_request(): # An error code has been sent, just exit + return + mname = 'do_' + self.command + if not hasattr(self, mname): + self.send_error(501, "Unsupported method (%s)" % `self.command`) + return + method = getattr(self, mname) + method() + + def send_error(self, code, message=None): + """Send and log an error reply. + + Arguments are the error code, and a detailed message. + The detailed message defaults to the short entry matching the + response code. + + This sends an error response (so it must be called before any + output has been generated), logs the error, and finally sends + a piece of HTML explaining the error to the user. + + """ + + try: + short, long = self.responses[code] + except KeyError: + short, long = '???', '???' + if not message: + message = short + explain = long + self.log_error("code %d, message %s", code, message) + self.send_response(code, message) + self.send_header("Content-Type", "text/html") + self.end_headers() + self.wfile.write(self.error_message_format % + {'code': code, + 'message': message, + 'explain': explain}) + + error_message_format = DEFAULT_ERROR_MESSAGE + + def send_response(self, code, message=None): + """Send the response header and log the response code. + + Also send two standard headers with the server software + version and the current date. + + """ + self.log_request(code) + if message is None: + if self.responses.has_key(code): + message = self.responses[code][0] + else: + message = '' + if self.request_version != 'HTTP/0.9': + self.wfile.write("%s %s %s\r\n" % + (self.protocol_version, str(code), message)) + self.send_header('Server', self.version_string()) + self.send_header('Date', self.date_time_string()) + + def send_header(self, keyword, value): + """Send a MIME header.""" + if self.request_version != 'HTTP/0.9': + self.wfile.write("%s: %s\r\n" % (keyword, value)) + + def end_headers(self): + """Send the blank line ending the MIME headers.""" + if self.request_version != 'HTTP/0.9': + self.wfile.write("\r\n") + + def log_request(self, code='-', size='-'): + """Log an accepted request. + + This is called by send_reponse(). + + """ + + self.log_message('"%s" %s %s', + self.requestline, str(code), str(size)) + + def log_error(self, *args): + """Log an error. + + This is called when a request cannot be fulfilled. By + default it passes the message on to log_message(). + + Arguments are the same as for log_message(). + + XXX This should go to the separate error log. + + """ + + apply(self.log_message, args) + + def log_message(self, format, *args): + """Log an arbitrary message. + + This is used by all other logging functions. Override + it if you have specific logging wishes. + + The first argument, FORMAT, is a format string for the + message to be logged. If the format string contains + any % escapes requiring parameters, they should be + specified as subsequent arguments (it's just like + printf!). + + The client host and current date/time are prefixed to + every message. + + """ + + sys.stderr.write("%s - - [%s] %s\n" % + (self.address_string(), + self.log_date_time_string(), + format%args)) + + def version_string(self): + """Return the server software version string.""" + return self.server_version + ' ' + self.sys_version + + def date_time_string(self): + """Return the current date and time formatted for a message header.""" + now = time.time() + year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now) + s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( + self.weekdayname[wd], + day, self.monthname[month], year, + hh, mm, ss) + return s + + def log_date_time_string(self): + """Return the current time formatted for logging.""" + now = time.time() + year, month, day, hh, mm, ss, x, y, z = time.localtime(now) + s = "%02d/%3s/%04d %02d:%02d:%02d" % ( + day, self.monthname[month], year, hh, mm, ss) + return s + + weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] + + monthname = [None, + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + + def address_string(self): + """Return the client address formatted for logging. + + This version looks up the full hostname using gethostbyaddr(), + and tries to find a name that contains at least one dot. + + """ + + host, port = self.client_address + return socket.getfqdn(host) + + # Essentially static class variables + + # The version of the HTTP protocol we support. + # Don't override unless you know what you're doing (hint: incoming + # requests are required to have exactly this version string). + protocol_version = "HTTP/1.0" + + # The Message-like class used to parse headers + MessageClass = mimetools.Message + + # Table mapping response codes to messages; entries have the + # form {code: (shortmessage, longmessage)}. + # See http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html + responses = { + 200: ('OK', 'Request fulfilled, document follows'), + 201: ('Created', 'Document created, URL follows'), + 202: ('Accepted', + 'Request accepted, processing continues off-line'), + 203: ('Partial information', 'Request fulfilled from cache'), + 204: ('No response', 'Request fulfilled, nothing follows'), + + 301: ('Moved', 'Object moved permanently -- see URI list'), + 302: ('Found', 'Object moved temporarily -- see URI list'), + 303: ('Method', 'Object moved -- see Method and URL list'), + 304: ('Not modified', + 'Document has not changed singe given time'), + + 400: ('Bad request', + 'Bad request syntax or unsupported method'), + 401: ('Unauthorized', + 'No permission -- see authorization schemes'), + 402: ('Payment required', + 'No payment -- see charging schemes'), + 403: ('Forbidden', + 'Request forbidden -- authorization will not help'), + 404: ('Not found', 'Nothing matches the given URI'), + + 500: ('Internal error', 'Server got itself in trouble'), + 501: ('Not implemented', + 'Server does not support this operation'), + 502: ('Service temporarily overloaded', + 'The server cannot process the request due to a high load'), + 503: ('Gateway timeout', + 'The gateway server did not receive a timely response'), + + } + + +def test(HandlerClass = BaseHTTPRequestHandler, + ServerClass = HTTPServer): + """Test the HTTP request handler class. + + This runs an HTTP server on port 8000 (or the first command line + argument). + + """ + + if sys.argv[1:]: + port = int(sys.argv[1]) + else: + port = 8000 + server_address = ('', port) + + httpd = ServerClass(server_address, HandlerClass) + + sa = httpd.socket.getsockname() + print "Serving HTTP on", sa[0], "port", sa[1], "..." + httpd.serve_forever() + + +if __name__ == '__main__': + 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 @@ +// +// CPP file for semantic-ia-utest +// completion engine unit tests. +// +#include "testdoublens.hpp" + +namespace Name1 { + namespace Name2 { + + Foo::Foo() + { + p// -1- + // #1# ( "pMumble" "publishStuff" ) + ; + } + + int Foo::get() // ^1^ + { + p// -2- + // #2# ( "pMumble" "publishStuff" ) + ; + return 0; + } + + void Foo::publishStuff(int /* a */, int /* b */) // ^2^ + { + } + + void Foo::sendStuff(int /* a */, int /* b */) // ^3^ + { + } + + } // namespace Name2 +} // namespace Name1 + +// Test multiple levels of metatype expansion +int test_fcn () { + stage3_Foo MyFoo; + + MyFoo.// -3- + // #3# ( "Mumble" "get" ) + ; + + Name1::Name2::F//-4- + // #4# ( "Foo" ) + ; + + // @TODO - get this working... + Name1::stage2_Foo::M//-5- + /// #5# ( "Mumble" ) + ; +} + +stage3_Foo foo_fcn() { + // Can we go "up" to foo with senator-go-to-up-reference? +} + + +// Second test from Ravikiran Rajagopal + +namespace A { + class foo { + public: + void aa(); + void bb(); + }; +} +namespace A { + class bar { + public: + void xx(); + public: + foo myFoo; + }; + + void bar::xx() + { + myFoo.// -6- <--- cursor is here after the dot + // #6# ( "aa" "bb" ) + ; + } +} + +// Double namespace example from Hannu Koivisto +// +// This is tricky because the parent class "Foo" is found within the +// scope of B, so the scope calculation needs to put that together +// before searching for parents in scope. +namespace a { + namespace b { + + class Bar : public Foo + { + int baz(); + }; + + int Bar::baz() + { + return dum// -7- + // #7# ( "dumdum" ) + ; + } + + } // namespace b +} // namespace a + +// Three namespace example from Hannu Koivisto +// +// This one is special in that the name e::Foo, where "e" is in +// the scope, and not referenced from the global namespace. This +// wasn't previously handled, so the fullscope needed to be added +// to the list of things searched when in split-name decent search mode +// for scopes. + +namespace d { + namespace e { + + class Foo + { + public: + int write(); + }; + + } // namespace d +} // namespace e + + +namespace d { + namespace f { + + class Bar + { + public: + int baz(); + + private: + e::Foo &foo; + }; + + int Bar::baz() + { + return foo.w// -8- + // #8# ( "write" ) + ; + } + + } // namespace f +} // 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 @@ +// +// Header file used in one of the ia-utest tests. +// +namespace Name1 { + namespace Name2 { + + class Foo + { + typedef unsigned int Mumble; + public: + Foo(); + ~Foo(); + int get(); + + private: + void publishStuff(int a, int b); + + void sendStuff(int a, int b); + + Mumble* pMumble; + }; + + typedef Foo stage1_Foo; + + } // namespace Name2 + + typedef Name2::stage1_Foo stage2_Foo; + + typedef Name2::Foo decl_stage1_Foo; + +} // namespace Name1 + +typedef Name1::stage2_Foo stage3_Foo; + + +// Double namespace from Hannu Koivisto +namespace a { + namespace b { + + class Foo + { + struct Dum { + int diDum; + }; + + protected: + mutable a::b::Foo::Dum dumdum; + }; + + } // namespace b +} // 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 @@ +// Test parsing of friends and how they are used in completion. +/* + >> Thanks Damien Profeta for the nice example. + > + > I paste a small example. + > It would be great if friend can be well parsed and even greater if + > class B can access to all the members of A. +*/ + +class Af // %2% ( ( "testfriends.cpp" ) ( "Af" "B::testB" ) ) +{ +public: + int pubVar; +private: + int privateVar; + + friend class B; + +}; + +class B +{ +public: + int testB(); + int testAB(); + +}; + + +int B::testB() { + Af classA; + classA.//-1- + ; //#1# ( "privateVar" "pubVar" ) +} + +int B::testAB() { // %1% ( ( "testfriends.cpp" ) ( "B" "B::testAB" ) ) +} diff --git a/test/cedet/tests/testjavacomp.java b/test/cedet/tests/testjavacomp.java new file mode 100644 index 00000000000..0c2604f5bf1 --- /dev/null +++ b/test/cedet/tests/testjavacomp.java @@ -0,0 +1,69 @@ +/** testjavacomp.java --- + * + * Copyright (C) 2009 Eric M. Ludlam + * + * Author: Eric M. Ludlam <eric@siege-engine.com> + * X-RCS: $Id: testjavacomp.java,v 1.1.2.1 2009/09/20 04:00:18 cyd Exp $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +package tests.testjavacomp; + +class secondClass { + private void scFuncOne() { } + public void scFuncOne() { } +} + + +public class testjavacomp { + + private int funcOne() { } + private int funcTwo() { } + private char funcThree() { } + + class nestedClass { + private void ncFuncOne() { } + public void ncFuncOne() { } + } + + public void publicFunc() { + + int i; + + i = fu// -1- + // #1# ( "funcOne" "funcTwo" ) + ; + + fu// -2- + // #2# ( "funcOne" "funcThree" "funcTwo" ) + ; + + secondClass SC; + + SC.//-3- + // #3# ( "scFuncOne" ) + ; + + nestedClass NC; + + // @todo - need to fix this? I don't know if this is legal java. + NC.// - 4- + // #4# ( "ncFuncOne" ) + ; + } + +} // 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 @@ +// Test NSP (Name space parent) +// +// Test dereferencing parents based on local parent scope. +// +// Derived from data David Engster provided. + +namespace nsp { + + class rootclass { + public: + int fromroot() {}; + }; + +} + +namespace nsp { + class childclass : public rootclass { + public: + int fromchild() {}; + }; +} + +void myfcn_not_in_ns (void) { + nsp::childclass test; + + test.// -1- + ; // #1# ( "fromchild" "fromroot" ) +} diff --git a/test/cedet/tests/testpolymorph.cpp b/test/cedet/tests/testpolymorph.cpp new file mode 100644 index 00000000000..fea842d6902 --- /dev/null +++ b/test/cedet/tests/testpolymorph.cpp @@ -0,0 +1,131 @@ +/** testpolymorph.cpp --- A sequence of polymorphism examples. + * + * Copyright (C) 2009 Eric M. Ludlam + * + * Author: Eric M. Ludlam <eric@siege-engine.com> + * X-RCS: $Id: testpolymorph.cpp,v 1.1.2.1 2009/09/20 04:00:18 cyd Exp $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <cmath> + +// Test 1 - Functions w/ prototypes +namespace proto { + + int pt_func1(int arg1); + int pt_func1(int arg1) { + return 0; + } + +} + +// Test 2 - Functions w/ different arg lists. +namespace fcn_poly { + + int pm_func(void) { + return 0; + } + int pm_func(int a) { + return a; + } + int pm_func(char a) { + return int(a); + } + int pm_func(double a) { + return int(floor(a)); + } + +} + +// Test 3 - Methods w/ differet arg lists. +class meth_poly { +public: + int pm_meth(void) { + return 0; + } + int pm_meth(int a) { + return a; + } + int pm_meth(char a) { + return int(a); + } + int pm_meth(double a) { + return int(floor(a)); + } + +}; + +// Test 4 - Templates w/ partial specifiers. +namespace template_partial_spec { + template <typename T> class test + { + public: + void doSomething(T t) { }; + }; + + template <typename T> class test<T *> + { + public: + void doSomething(T* t) { }; + }; +} + +// Test 5 - Templates w/ full specicialization which may or may not share +// common functions. +namespace template_full_spec { + template <typename T> class test + { + public: + void doSomething(T t) { }; + void doSomethingElse(T t) { }; + }; + + template <> class test<int> + { + public: + void doSomethingElse(int t) { }; + void doSomethingCompletelyDifferent(int t) { }; + }; +} + +// Test 6 - Dto., but for templates with multiple parameters. +namespace template_multiple_spec { + template <typename T1, typename T2> class test + { + public: + void doSomething(T1 t) { }; + void doSomethingElse(T2 t) { }; + }; + + template <typename T2> class test<int, T2> + { + public: + void doSomething(int t) { }; + void doSomethingElse(T2 t) { }; + }; + + template <> class test<float, int> + { + public: + void doSomething(float t) { }; + void doSomethingElse(int t) { }; + void doNothing(void) { }; + }; +} + + +// 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 @@ +/* Attempt to test the C preprocessor + * + */ + +int some_fcn (){} + + +#ifndef MOOSE +int pre_show_moose(){} +#endif + +#ifdef MOOSE +int pre_dont_show_moose(){} +#endif + +#if !defined(MOOSE) +int pre_show_moose_if(){} +#endif + +#if defined(MOOSE) +int pre_dont_show_moose_if(){} +#endif + +#define MOOSE + +#if 0 +int dont_show_function_if_0(){} +#endif + +#if 1 +int show_function_if_1(){} +#endif + +#ifdef MOOSE +int moose_function(){} +#endif + +#ifndef MOOSE +int dont_show_moose(){} +#endif + +#if defined(MOOSE) +int moose_function_if(){} +#endif + +#if !defined(MOOSE) +int dont_show_moose_if() {} +#endif + +#undef MOOSE + +#ifdef MOOSE +int no_handy_moose(){} +#endif + +#ifndef MOOSE +int show_moose_else() {} +#else +int no_show_moose_else(){} +#endif + + +#ifdef MOOSE +int no_show_moose_else_2() {} +#else +int show_moose_else_2() {} +#endif + +#if defined(MOOSE) +int no_show_moose_elif() {} +#elif !defined(MOOSE) +int show_moose_elif() {} +#else +int no_show_moose_elif_else() {} +#endif + +#if defined(MOOSE) +int no_show_moose_if_elif_2() {} +#elif defined(COW) +int no_show_moose_elif_2() {} +#else +int show_moose_elif_else() {} +#endif + 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 @@ +/* Example provided by Hannes Janetzek */ + +struct Test { int test; }; + +#define BLA(_type) \ + _type *bla = (_type*) malloc(sizeof(_type)); + +#define BLUB(_type) \ + (_type*)malloc(sizeof(_type)); + +#define FOO(_type) \ + _type *foo = BLUB(_type); + +#define BAR(_type) \ + _type *bar = (*_type)BLUB(_type); + +int main(int argc, char *argv[]) { + BLA(Test); + bla->// -1- + ; // #1# ( "test" ) + + FOO(Test); + foo->// -2- + ; // #2# ( "test" ) + + BAR(Test); + bar->// -3- + ; // #3# ( "test" ) +} 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 @@ +/* Test CPP/SPP Replacement + */ + +/* TEST: The EMU keyword doesn't screw up the function defn. */ +#define EMU +#define EMU2 /*comment*/ +char EMU parse_around_emu EMU2 (EMU) +{ +} + +/* TEST: A simple word can be replaced in a definition. */ +#define SUBFLOAT /* Some Float */ float +SUBFLOAT returnanfloat() +{ +} + +/* TEST: Punctuation an be replaced in a definition. */ +#define COLON : +int foo COLON COLON bar () +{ +} + +/* TEST: Multiple lexical characters in a definition */ +#define SUPER mysuper:: +int SUPER baz () +{ +} + +/* TEST: Macro replacement. */ +#define INT_FCN(name) int name (int in) + +INT_FCN(increment) { + return in+1; +} + +/* TEST: Macro replacement with complex args */ +#define P_(proto) () + +int myFcn1 P_((a,b)); + +#define P__(proto) proto + +int myFcn2 P__((int a, int b)); +int myFcn3 (int a, int b); + +/* TEST: Multiple args to a macro. */ +#define MULTI_ARGS(name, field1, field2, field3) struct name { int field1; int field2; int field3; } + +MULTI_ARGS(ma_struct, moose, penguin, emu); + +/* TEST: Macro w/ args, but no body. */ +#define NO_BODY(name) + +NO_BODY(Moose); + +/* TEST: Not a macro with args, but close. */ +#define NOT_WITH_ARGS (moose) + +int not_with_args_fcn NOT_WITH_ARGS +{ +} + +/* TEST: macro w/ continuation. */ +#define WITH_CONT \ + continuation_symbol + +int WITH_CONT () { }; + +/* TEST: macros in a macro - tail processing */ +#define tail_with_args_and_long_name(a) (int a) +#define int_arg tail_with_args_and_long_name + +int tail int_arg(q) {} + +/* TEST: macros used improperly. */ +#define tail_fail tail_with_args_and_long_name(q) + +int tail_fcn tail_fail(q); + +/* TEST: feature of CPP from LSD <lsdsgster@...> */ +#define __gthrw_(name) __gthrw_ ## name + +int __gthrw_(foo) (int arg1) { } + +/* TEST: macros using macros */ +#define macro_foo foo +#define mf_declare int macro_foo + +mf_declare; + +/* TEST: macros with args using macros */ +#define Amacro(A) (int A) +#define mf_Amacro(B) int B Amacro(B) + +mf_Amacro(noodle); + +/* TEST: Double macro using the argument stack. */ +#define MACRO0(name) int that_ ## name(int i); +#define MACRO1(name) int this_ ## name(int i); +#define MACRO2(name) MACRO0(name) MACRO1(name) + +MACRO2(foo) + +/* TEST: The G++ namespace macro hack. Not really part of SPP. */ +_GLIBCXX_BEGIN_NAMESPACE(baz) + + int bazfnc(int b) { } + +_GLIBCXX_END_NAMESPACE; + +_GLIBCXX_BEGIN_NESTED_NAMESPACE(foo,bar) + + int foo_bar_func(int a) { } + +_GLIBCXX_END_NESTED_NAMESPACE; + + +/* TEST: The VC++ macro hack. */ +_STD_BEGIN + + int inside_std_namespace(int a) { } + +_STD_END + +/* TEST: Recursion prevention. CPP doesn't allow even 1 level of recursion. */ +#define STARTMACRO MACROA +#define MACROA MACROB +#define MACROB MACROA + +int STARTMACRO () { + +} + + +/* 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 @@ +/* What the SPP replace file would looklike with MACROS replaced. + */ + +/* TEST: The EMU keyword doesn't screw up the function defn. */ +char parse_around_emu () +{ +} + +/* TEST: A simple word can be replaced in a definition. */ +float returnanfloat() +{ +} + +/* TEST: Punctuation an be replaced in a definition. */ +int foo::bar () +{ +} + +/* TEST: Multiple lexical characters in a definition */ +int mysuper::baz () +{ +} + +/* TEST: Macro replacement. */ +int increment (int in) { + return in+1; +} + +/* TEST: Macro replacement with complex args */ +int myFcn1 (); + +int myFcn2 (int a, int b); +int myFcn3 (int a, int b); + +/* TEST: Multiple args to a macro. */ +struct ma_struct { int moose; int penguin; int emu; }; + +/* TEST: Macro w/ args, but no body. */ + +/* TEST: Not a macro with args, but close. */ +int not_with_args_fcn (moose) +{ +} + +/* TEST: macro w/ continuation. */ +int continuation_symbol () { }; + +/* TEST: macros in a macro - tail processing */ + +int tail (int q) {} + +/* TEST: macros used impropertly. */ + +int tail_fcn(int q); + +/* TEST: feature of CPP from LSD <lsdsgster@...> */ + +int __gthrw_foo (int arg1) { } + +/* TEST: macros using macros */ +int foo; + +/* TEST: macros with args using macros */ +int noodle(int noodle); + +/* TEST: Double macro using the argument stack. */ +int that_foo(int i); +int this_foo(int i); + +/* TEST: The G++ namespace macro hack. Not really part of SPP. */ +namespace baz { + + int bazfnc(int b) { } + +} + +namespace foo { namespace bar { + + int foo_bar_func(int a) { } + + } +} + +/* TEST: The VC++ macro hack. */ +namespace std { + + int inside_std_namespace(int a) { } + +} + +/* TEST: Recursion prevention. CPP doesn't allow even 1 level of recursion. */ +int MACROA () { + +} + + +/* 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 @@ +// Combinations of templates and structure inheritance. +// +// Created by Alex Ott. + +template <typename DerivedT> +struct grammar { +public: + typedef grammar<DerivedT> self_t; + typedef DerivedT const& embed_t; + grammar() {} + ~grammar() { } + void use_parser() const { } + void test1() { } +}; + +struct PDFbool_parser : public grammar<PDFbool_parser> { + PDFbool_parser() {} + template <typename scannerT> struct definition { + typedef typename scannerT::iterator_t iterator_t; + int top; + definition(const PDFbool_parser& /*self*/) { + return ; + } + const int start() const { + return top; + } + }; +}; + +int main(void) { + PDFbool_parser PDFbool_p = PDFbool_parser(); + PDFbool_p.//-1- + ; + // #1# ("definition" "embed_t" "self_t" "test1" "use_parser") +} + +// ---------------------------------------------------------------------- + +template <class Derived> struct Base { +public: + void interface() + { + // ... + static_cast<Derived*>(this)->implementation(); + // ... + } + + static void static_func() + { + // ... + Derived::static_sub_func(); + // ... + } +}; + +struct Derived : Base<Derived> { + void implementation() { } + static void static_sub_func() { } +}; + +int foo () { + Derived d; + d.//-2- + ; + // #2# ("implementation" "interface" "static_func" "static_sub_func") +} 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 @@ +/* Special test file for Semantic Analyzer and complex C++ inheritance. + */ + +//#include <iostream> +#include "testsubclass.hh" + +void animal::moose::setFeet(int numfeet) //^1^ +{ + if (numfeet > 4) { + std::cerr << "Why would a moose have more than 4 feet?" << std::endl; + return; + } + + fFeet = numfeet; +} + +int animal::moose::getFeet() //^2^ +{ + return fFeet; +} + +void animal::moose::doNothing() //^3^ +{ + animal::moose foo(); + + fFeet = N// -15- + ; // #15# ( "NAME1" "NAME2" "NAME3" ) +} + + +void deer::moose::setAntlers(bool have_antlers) //^4^ +{ + fAntlers = have_antlers; +} + +bool deer::moose::getAntlers() //^5^ +// %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) ) +{ + return fAntlers; +} + +bool i_dont_have_symrefs() +// %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs")) +{ +} + +void deer::moose::doSomething() //^6^ +{ + // All these functions should be identified by semantic analyzer. + getAntlers(); + setAntlers(true); + + getFeet(); + setFeet(true); + + doNothing(); + + fSomeField = true; + + fIsValid = true; +} + +void deer::alces::setLatin(bool l) { + fLatin = l; +} + +bool deer::alces::getLatin() { + return fLatin; +} + +void deer::alces::doLatinStuff(moose moosein) { + // All these functions should be identified by semantic analyzer. + getFeet(); + setFeet(true); + + getLatin(); + setLatin(true); + + doNothing(); + + deer::moose foo(); + + +} + +moose deer::alces::createMoose() +{ + moose MooseVariableName; + bool tmp; + int itmp; + bool fool; + int fast; + + MooseVariableName = createMoose(); + + doLatinStuff(MooseVariableName); + + tmp = this.f// -1- + // #1# ( "fAlcesBool" "fIsValid" "fLatin" ) + ; + + itmp = this.f// -2- + // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" ) + ; + + tmp = f// -3- + // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" ) + ; + + itmp = f// -4- + // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" ) + ; + + MooseVariableName = m// -5- + // #5# ( "moose" ) + + return MooseVariableName; +} + +/** Test Scope Changes + * + * This function is rigged to make sure the scope changes to account + * for different locations in local variable parsing. + */ +int someFunction(int mPickle) +{ + moose mMoose = deer::alces::createMoose(); + + if (mPickle == 1) { + + int mOption1 = 2; + + m// -5- + // #5# ( "mMoose" "mOption1" "mPickle" ) + ; + + } else { + + int mOption2 = 2; + + m// -6- + // #6# ( "mMoose" "mOption2" "mPickle" ) + ; + } + +} + +// Thanks Ming-Wei Chang for this next example. + +namespace pub_priv { + + class A{ + private: + void private_a(){} + public: + void public_a(); + }; + + void A::public_a() { + A other_a; + + other_a.p// -7- + // #7# ( "private_a" "public_a" ) + ; + } + + int some_regular_function(){ + A a; + a.p// -8- + // #8# ( "public_a" ) + ; + return 0; + } + +} + + +/** Test Scope w/in a function (non-method) with classes using + * different levels of inheritance. + */ +int otherFunction() +{ + sneaky::antelope Antelope(1); + sneaky::jackalope Jackalope(1); + sneaky::bugalope Bugalope(1); + + Antelope.// -9- + // #9# ( "fAntyPublic" "fQuadPublic" "testAccess") + ; + + Jackalope.// -10- + // #10# ( "fBunnyPublic" "testAccess") + ; + + Jackalope// @1@ 6 + ; + Jackalope; + Jackalope; + Jackalope; + + Bugalope.// -11- + // #11# ( "fBugPublic" "testAccess") + ; + Bugalope// @2@ 3 + ; +} + +/** Test methods within each class for types of access to the baseclass. + */ + +bool sneaky::antelope::testAccess() //^7^ +{ + this.// -12- + // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" ) + ; +} + +bool sneaky::jackalope::testAccess() //^8^ +{ + this.// -13- + // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" ) + ; +} + +bool sneaky::bugalope::testAccess() //^9^ +{ + this.// -14- + // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" ) + ; +} + 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 @@ +/* Special test file for Semantic Analyzer and complex C++ inheritance. + * + * Header file for testsubclass.cpp with class defns but no + * implementations. + */ + +//#include <cmath> +// #include <stdio.h> + +#ifndef TESTSUBCLASS_HH +#define TESTSUBCLASS_HH + +namespace animal { + + class moose { + public: + moose() : fFeet(0), + fIsValid(false) + { } + + virtual void setFeet(int); + int getFeet(); + + void doNothing(); + + enum moose_enum { + NAME1, NAME2, NAME3 }; + + + protected: + + bool fIsValid; + int fIsProtectedInt; + + private: + int fFeet; // Usually 2 or 4. + bool fIsPrivateBool; + + }; // moose + + int two_prototypes(); + int two_prototypes(); + + class quadruped { + public: + quadruped(int a) : fQuadPrivate(a) + { } + + int fQuadPublic; + + protected: + int fQuadProtected; + + private: + int fQuadPrivate; + + }; + +} + + +namespace deer { + + class moose : public animal::moose { + public: + moose() : fAntlers(false) + { } + + void setAntlers(bool); + bool getAntlers(); + + void doSomething(); + + protected: + + bool fSomeField; + + private: + bool fAntlers; + + }; + +} // deer + +// A second namespace of the same name will test the +// namespace merging needed to resolve deer::alces +namespace deer { + + class alces : public animal::moose { + public: + alces(int lat) : fLatin(lat) + { } + + void setLatin(bool); + bool getLatin(); + + void doLatinStuff(moose moosein); // for completion testing + + moose createMoose(); // for completion testing. + + protected: + bool fAlcesBool; + int fAlcesInt; + + private: + bool fLatin; + int fGreek; + }; + +}; + +// A third namespace with classes that does protected and private inheritance. +namespace sneaky { + + class antelope : public animal::quadruped { + + public: + antelope(int a) : animal::quadruped(), + fAntyProtected(a) + {} + + int fAntyPublic; + + bool testAccess(); + + protected: + int fAntyProtected; + + private : + int fAntyPrivate; + + }; + + class jackalope : protected animal::quadruped { + + public: + jackalope(int a) : animal::quadruped(), + fBunny(a) + {} + + int fBunnyPublic; + + bool testAccess(); + + protected: + bool fBunnyProtected; + + private : + bool fBunnyPrivate; + + }; + + // Nothing specified means private. + class bugalope : /* private*/ animal::quadruped { + + public: + bugalope(int a) : animal::quadruped(), + fBug(a) + {} + + int fBugPublic; + + bool testAccess(); + protected: + bool fBugProtected; + + private : + bool fBugPrivate; + + }; + + +}; + +#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 @@ +// Templates Test file: +// Written by 'Raf' + +template <class T, int U, class V> +class read_ref { +public: + const T* read_ref_member_one( T); + const V* read_ref_member_two(); +}; + +namespace NS { + template <class T, int U, class V> + class ref { + public: + read_ref<T,10,V> operator->() { + m_// -1- + ; + // #1# ( "m_datas" ) + } + + private: + T m_datas[U]; + }; + +} + +class FooOne { +public: + int fooOneMember(); +}; + +class FooTwo { +public: + int fooTwoMember(); +}; + +class FooThree { +public: + int fooThreeMember(); + + FooOne * operator->(); +}; + +typedef ref<FooOne, 10,FooTwo> Test; + +using NS; + +void +main(void) { + ref<FooOne, 10, FooTwo> v; + + v->read_ref_member_one()-> // -2- + ; + // #2# ( "fooOneMember" ) + + v->read_ref_member_two()-> // -3- + ; + // #3# ( "fooTwoMember" ) + + v-> // -4- + ; + // #4# ( "read_ref_member_one" "read_ref_member_two" ) + + Test t; + + t->read_ref_member_two()-> // -5- + ; + // #5# ( "fooTwoMember" ) + + ref<FooOne, 10, FooThree> v2; + + v2->read_ref_member_two()-> // -6- + ; + // #6# ( "fooOneMember" ) + + /* Try all these things by also specifying the namespace in the name. */ + NS::ref<FooOne, 10, FooTwo> v3; + + v3->read_ref_member_one()-> // -7- + ; + // #7# ( "fooOneMember" ) + + v3->read_ref_member_two()-> // -8- + ; + // #8# ( "fooTwoMember" ) + + v3->read_ref_member_two// @1@ 5 + ; + +} 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 @@ +// Sample with some fake bits out of std::string +// +// Thanks Ming-Wei Chang for these examples. + +namespace std { + + template <T>class basic_string { + + public: + void resize(int); + + }; + +} + +typedef std::basic_string<char> mstring; + +using namespace std; +typedef basic_string<char> bstring; + + +int main(){ + mstring a; + + a.// -1- + ; + // #1# ( "resize" ) + + bstring b; + // It doesn't work here. + b.// -2- + ; + // #2# ( "resize" ) + + return 0; +} + + +// ------------------ + +class Bar +{ +public: + void someFunc() {} + +}; + +typedef Bar new_Bar; + +template <class mytype> +class TBar +{ +public: + void otherFunc() {} + +}; + +typedef TBar<char> new_TBar; + +int main() +{ + new_Bar nb; + new_TBar ntb; + + nb.// -3- + ; + // #3# ("someFunc") + + ntb.// -4- + ; + // #4# ("otherFunc") + + return 0; +} 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 @@ +// Test using statements in C++ + +#include <adstdio.h> + +#include <testusing.hh> + +namespace moose { + + class MyClass; + class Point; + + typedef MyClass snerk; +} + +namespace moose { + + class Point; + class MyClass; + +} + +namespace { + + int global_variable = 0; + +}; + +using moose::MyClass; + +void someFcn() { + + MyClass f; + + f.//-1- + ; //#1# ( "getVal" "setVal" ) + +} + +// Code from Zhiqiu Kong + +namespace panda { + + using namespace bread_name; + + int func() + { + bread test; + test.//-2- + ;// #2# ( "geta" ) + return 0; + } +} + +// Local using statements and aliased types +// Code from David Engster + +void func2() +{ + using namespace somestuff; + OneClass f; + f.//-3- + ; //#3# ( "aFunc" "anInt" ) +} + +void func3() +{ + using somestuff::OneClass; + OneClass f; + f.//-4- + ; //#4# ( "aFunc" "anInt" ) +} + +// Dereferencing alias types created through 'using' statements + +// Alias with fully qualified name +void func4() +{ + otherstuff::OneClass f; + f. //-5- + ; //#5# ( "aFunc" "anInt" ) +} + +// Alias through namespace directive +void func5() +{ + using namespace otherstuff; + OneClass f; + f. //-6- + ; //#6# ( "aFunc" "anInt" ) +} + +// Check name hiding +void func6() +{ + using namespace morestuff; + OneClass f; // Alias for somestuff::OneClass + f. //-7- + ; //#7# ( "aFunc" "anInt" ) + aStruct g; // This however is morestuff::aStruct ! + g. //-8- + ; //#8# ( "anotherBar" "anotherFoo" ) +} + +// Alias of an alias +// Currently doesn't work interactively for some reason. +void func6() +{ + using namespace evenmorestuff; + OneClass f; + f. //-7- + ; //#7# ( "aFunc" "anInt" ) +} + +// Alias for struct in nested namespace, fully qualified +void func7() +{ + outer::StructNested f; + f.//-8- + ; //#8# ( "one" "two" ) +} + +// Alias for nested namespace +void func8() +{ + using namespace outerinner; + StructNested f; + AnotherStruct g; + f.//-9- + ; //#9# ( "one" "two" ) + g.//-10- + ; //#10# ( "four" "three" ) +} 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 @@ +// test usings header file. + +namespace moose { + + class Point; + + class MyClass; + +} + + +namespace moose { + + class Point; + + class MyClass { + public: + MyClass() : fVal(0) { + } + + ~MyClass() {}; + + /** + * fVal Accessors + * @{ + */ + int getVal() const { + return fVal; + } + void setVal(int Val) const { + fVal = Val; + } + /** + * @} + */ + private: + int fVal; + }; + +} + +namespace deer { + + class Pickle; + +}; + +// Code from Zhiqiu Kong + +#ifndef BREAD_H +#define BREAD_H + +namespace bread_name { + class bread + { + public: + void geta(); + private: + int m_a; + int m_b; + }; +} + +#endif + +// Code from David Engster +// Creating alias types through 'using' trickery + +namespace somestuff { + class OneClass { + public: + void aFunc(); + int anInt; + }; + struct aStruct { + int foo; + int bar; + }; +} + +namespace otherstuff { + // make otherstuff::OneClass an alias for somestuff::OneClass + using somestuff::OneClass; +} + +namespace morestuff { + // make morestuff an alias namespace for somestuff + using namespace somestuff; + // but hide aStruct with own type + struct aStruct { + int anotherFoo; + int anotherBar; + }; +} + +// We can also create an alias for an alias +namespace evenmorestuff { + using otherstuff::OneClass; +} + +// Now with nested namespaces +namespace outer { + namespace inner { + struct StructNested { + int one; + int two; + }; + struct AnotherStruct { + int three; + int four; + }; + } +} + +// Elevate the first struct into 'outer' +// so that we can access it via 'outer::StructNested' +namespace outer { + using outer::inner::StructNested; +} + +// Create an alias for a nested namespace +namespace outerinner { + // equivalent to 'namespace outerinner = outer::inner;' + using namespace outer::inner; +} 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 @@ +/* + * Test variable and function names, lists of variables on one line, etc. + */ + +struct independent { + int indep_1; + int indep_2; +}; + +struct independent var_indep_struct; + +struct { + int unnamed_1; + int unnamed_2; +} var_unamed_struct; + +struct { + int unnamed_3; + int unnamed_4; +} var_un_2, var_un_3; + +struct inlinestruct { + int named_1; + int named_2; +} var_named_struct; + +struct inline2struct { + int named_3; + int named_4; +} var_n_2, var_n_3; + +/* Structures with names that then declare variables + * should also be completable. + * + * Getting this to work is the bugfix in semantic-c.el CVS v 1.122 + */ +struct inlinestruct in_var1; +struct inline2struct in_var2; + +int test_1(int var_arg1) { + + var_// -1- + ; // #1# ("var_arg1" "var_indep_struct" "var_n_2" "var_n_3" "var_named_struct" "var_un_2" "var_un_3" "var_unamed_struct") + + var_indep_struct.// -2- + ; // #2# ( "indep_1" "indep_2" ) + + var_unamed_struct.// -3- + ; // #3# ( "unnamed_1" "unnamed_2" ) + + var_named_struct.// -4- + ; // #4# ( "named_1" "named_2" ) + + var_un_2.// -5- + ; // #5# ( "unnamed_3" "unnamed_4" ) + var_un_3.// -6- + ; // #6# ( "unnamed_3" "unnamed_4" ) + + var_n_2.// -7- + ; // #7# ( "named_3" "named_4" ) + var_n_3.// -8- + ; // #8# ( "named_3" "named_4" ) + + in_// -9- + ; // #9# ( "in_var1" "in_var2" ) + + in_var1.// -10- + ; // #10# ( "named_1" "named_2") + in_var2.// -11- + ; // #11# ( "named_3" "named_4") +} |