From 0f7163ab89cc6158dbb7a382b67da5ce200f42f1 Mon Sep 17 00:00:00 2001 From: Eric Ludlam Date: Sun, 27 Oct 2019 20:31:34 -0400 Subject: * test/manual/cedet/tests/: New files for semantic-utest-ia.el * test/manual/cedet/tests/test.mk, test/manual/cedet/tests/test.srt, test/manual/cedet/tests/test.texi, test/manual/cedet/tests/testlocalvars.cpp, test/manual/cedet/tests/teststruct.cpp, test/manual/cedet/tests/testtemplates.cpp, test/manual/cedet/tests/testusing.cpp, test/manual/cedet/tests/testusing.hh, test/manual/cedet/tests/testvarnames.java. test/manual/cedet/tests/testwisent.wy: New files to be used by test/lisp/cedet/semantic-utest-ia.el. Author: Eric Ludlam --- test/manual/cedet/tests/test.mk | 18 ++ test/manual/cedet/tests/test.srt | 64 ++++++++ test/manual/cedet/tests/test.texi | 40 +++++ test/manual/cedet/tests/testlocalvars.cpp | 54 ++++++ test/manual/cedet/tests/teststruct.cpp | 86 ++++++++++ test/manual/cedet/tests/testtemplates.cpp | 149 +++++++++++++++++ test/manual/cedet/tests/testusing.cpp | 265 ++++++++++++++++++++++++++++++ test/manual/cedet/tests/testusing.hh | 176 ++++++++++++++++++++ test/manual/cedet/tests/testvarnames.java | 60 +++++++ test/manual/cedet/tests/testwisent.wy | 85 ++++++++++ 10 files changed, 997 insertions(+) create mode 100644 test/manual/cedet/tests/test.mk create mode 100644 test/manual/cedet/tests/test.srt create mode 100644 test/manual/cedet/tests/test.texi create mode 100644 test/manual/cedet/tests/testlocalvars.cpp create mode 100644 test/manual/cedet/tests/teststruct.cpp create mode 100644 test/manual/cedet/tests/testtemplates.cpp create mode 100644 test/manual/cedet/tests/testusing.cpp create mode 100644 test/manual/cedet/tests/testusing.hh create mode 100644 test/manual/cedet/tests/testvarnames.java create mode 100644 test/manual/cedet/tests/testwisent.wy (limited to 'test/manual/cedet') diff --git a/test/manual/cedet/tests/test.mk b/test/manual/cedet/tests/test.mk new file mode 100644 index 00000000000..edea97e7b98 --- /dev/null +++ b/test/manual/cedet/tests/test.mk @@ -0,0 +1,18 @@ +# A Test Makefile. -*-makefile-*- + +# This test is for a file in this test directory. Just a random one. +FILES=testdoub # -1- +# #1# ("testdoublens.cpp" "testdoublens.hpp" ) + +all: optional + +# This one completes on a variable name. +optional: $FIL # -2- + # #2# ("FILES") + compile $@ + +notoptional: opt # -3- + # #3# ("optional") + echo "Done." + +#end diff --git a/test/manual/cedet/tests/test.srt b/test/manual/cedet/tests/test.srt new file mode 100644 index 00000000000..b77cd4fbe29 --- /dev/null +++ b/test/manual/cedet/tests/test.srt @@ -0,0 +1,64 @@ +;; test.srt --- unit test support file for semantic-utest-ia + +;; Copyright (C) 2008-2019 Free Software Foundation, Inc. + +;; Author: Eric M. Ludlam + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs 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 GNU Emacs. If not, see . +;; + +set mode "c++-mode" +set escape_start "{{" +set escape_end "}}" + +context file + +template class :blank +"A test template for emacs lisp" +---- +---- + +template classic :blank +"A test template for emacs lisp" +---- +---- + +template variable :blank +"A test template for emacs lisp" +---- +---- + +template function :blank +"A test template for emacs lisp" +---- +---- + +template testarea :blank +"A test template for emacs lisp" +---- +{{ + +// This file is part of GNU Emacs. + +// GNU Emacs 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 3 of the License, or +// (at your option) any later version. + +// GNU Emacs 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 GNU Emacs. If not, see . + + +class foo { + foo *member; + char anArray[10]; +}; + +void func() +{ + foo local1; + foo* local2 = localvar.member; + foo* local3 = new foo(); + foo local4[10]; + char local5[5] = {'1','2','3','4','5'}; + char *local6 = "12345"; + char local7 = local.anArray[0]; + char local8 = true ? 10 : 11 ; + + // Check that all of the above was parsed + local//-1- + ; //#1# ("local1" "local2" "local3" "local4" "local5" "local6" "local7" "local8" ) + + local1.//-2- + ; //#2# ("anArray" "member") + + local2->//-3- + ; //#3# ("anArray" "member") + + local3->//-4- + ; //#4# ("anArray" "member") + + local4[0].//-5- + ; //#5# ("anArray" "member") +} diff --git a/test/manual/cedet/tests/teststruct.cpp b/test/manual/cedet/tests/teststruct.cpp new file mode 100644 index 00000000000..041483d1195 --- /dev/null +++ b/test/manual/cedet/tests/teststruct.cpp @@ -0,0 +1,86 @@ +// teststruct.cpp --- semantic-ia-utest completion engine unit tests + +// Copyright (C) 2008-2019 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs 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 3 of the License, or +// (at your option) any later version. + +// GNU Emacs 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 GNU Emacs. If not, see . + + +// Note: initially provided by by Alex Ott. + +template +struct grammar { +public: + typedef grammar self_t; + typedef DerivedT const& embed_t; + grammar() {} + ~grammar() { } + void use_parser() const { } + void test1() { } +}; + +struct PDFbool_parser : public grammar { + PDFbool_parser() {} + template 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 struct Base { +public: + void interface() + { + // ... + static_cast(this)->implementation(); + // ... + } + + static void static_func() + { + // ... + Derived::static_sub_func(); + // ... + } +}; + +struct Derived : Base { + 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/manual/cedet/tests/testtemplates.cpp b/test/manual/cedet/tests/testtemplates.cpp new file mode 100644 index 00000000000..18ee9ec10be --- /dev/null +++ b/test/manual/cedet/tests/testtemplates.cpp @@ -0,0 +1,149 @@ +// testtemplates.cpp --- semantic-ia-utest completion engine unit tests + +// Copyright (C) 2008-2019 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs 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 3 of the License, or +// (at your option) any later version. + +// GNU Emacs 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 GNU Emacs. If not, see . + + +// TODO - this probably means can't be part of emacs, as I don't know who this guy is. +// Written by 'Raf' + +template +class read_ref { +public: + const T* read_ref_member_one( T); + const V* read_ref_member_two(); +}; + +namespace NS { + template + class ref { + public: + read_ref 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 Test; + +using NS; + +void +main(void) { + ref 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 v2; + + v2->read_ref_member_two()-> // -6- + ; + // #6# ( "fooOneMember" ) + + /* Try all these things by also specifying the namespace in the name. */ + NS::ref v3; + + v3->read_ref_member_one()-> // -7- + ; + // #7# ( "fooOneMember" ) + + v3->read_ref_member_two()-> // -8- + ; + // #8# ( "fooTwoMember" ) + + v3->read_ref_member_two// @1@ 5 + ; + +} + +// More Namespace Magic using member constants. + +template +struct isFooLike { + static const bool value = false; +}; + +template <> +struct isFooLike { + static const bool value = true; +}; + + +template +class A { +public: + A(); + void foo() {}; +}; + + +template +class FooFour : public A::value> { +public: + bool bar() {} +}; + + +int main2() { + + FooFour ff; + + ff.// - 9- @ TODO - bring over patch from SF + ; // #9# ( "bar" "foo" ); + +} diff --git a/test/manual/cedet/tests/testusing.cpp b/test/manual/cedet/tests/testusing.cpp new file mode 100644 index 00000000000..1208c81fc36 --- /dev/null +++ b/test/manual/cedet/tests/testusing.cpp @@ -0,0 +1,265 @@ +// testusing.cpp --- semantic-ia-utest completion engine unit tests + +// Copyright (C) 2008-2019 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs 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 3 of the License, or +// (at your option) any later version. + +// GNU Emacs 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 GNU Emacs. If not, see . + + +#include + +#include + +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; + } +} + +namespace togglemoose { + + MyOtherClass::testToggle1() { //^1^ + // Impl for testToggle1 + } +} + +togglemoose::MyOtherClass::testToggle2() { //^3^ + // Impl for testToggle2 +} + +using togglemoose; + +MyOtherClass::testToggle3() { //^3^ + // Impl for testToggle3 +} + +// 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" ) +} + +// Check convetional namespace aliases +// - fully qualified - +void func9() +{ + alias_for_somestuff::OneClass c; + c.//-11- + ; //#11# ( "aFunc" "anInt" ) + alias_for_outerinner::AnotherStruct s; + s. //-12- + ; //#12# ( "four" "three" ) +} + +// - unqualified - +void func10() +{ + using namespace alias_for_somestuff; + OneClass c2; + c2.//-13- + ; //#13# ( "aFunc" "anInt" ) + using namespace alias_for_outerinner; + AnotherStruct s2; + s2.//-14- + ; //#14# ( "four" "three" ) +} + +// Completion on namespace aliases +void func11() +{ + alias_for_somestuff:://-15- + ; //#15# ( "OneClass" "aStruct") + alias_for_outerinner:://-16- + ; //#16# ( "AnotherStruct" "StructNested" ) +} + +// make sure unfound using statements don't crash stuff. +using something::cantbe::Found; + +void unfoundfunc() +{ + NotFound notfound; // Variable can't be found. + + notfound.//-17- + ; //#17# ( ) Nothing here since this is an undefined class + +} + +// Using statements can depend on previous ones... + +void acc_using() +{ + using namespace outer; + // This is effectively like 'using namespace outer::inner' + using namespace inner; + + StructNested sn; + sn.//-18- + ; //#18# ( "one" "two" ) +} + +// Check the same outside of function scope + +using namespace outer; +using namespace inner; + +void acc_using2() +{ + StructNested sn; + sn.//-19- + ; //#19# ( "one" "two" ) +} + +// Check if scope gets correctly generated, i.e., without us providing any +// hints in the form of an existing type + +void check_scope() +{ + using namespace first; + AAA//-20- + ; //#20# ( "AAA1" "AAA2" ) +} + +void check_scope2() +{ + using namespace third; + AAA//-21- + ; //#21# ( "AAA1" "AAA2" "AAA3" ) +} + +// Make sure this also works not only in functions + +namespace check_scope3 { + using namespace first; + AAA//-22- + ; //#22# ( "AAA1" "AAA2" ) +} diff --git a/test/manual/cedet/tests/testusing.hh b/test/manual/cedet/tests/testusing.hh new file mode 100644 index 00000000000..18a33dac46e --- /dev/null +++ b/test/manual/cedet/tests/testusing.hh @@ -0,0 +1,176 @@ +// testusing.hh --- semantic-ia-utest completion engine unit tests + +// Copyright (C) 2008-2019 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs 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 3 of the License, or +// (at your option) any later version. + +// GNU Emacs 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 GNU Emacs. If not, see . + +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 togglemoose { + + class MyOtherClass { + public: + int testToggle1(); + int testToggle2(); + int testToggle3(); + }; +} + +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; + }; + } +} + +// Namespace which pulls in one of its own nested namespaces +namespace first { + class AAA1; + namespace second { + class AAA2; + } + // Elevate nested namespace into first one + using namespace second; +} + +namespace third { + using namespace first; + class AAA3; +} + + +// 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; +} + +// Create namespace alias +namespace alias_for_somestuff = somestuff; +// Same for nested namespace +namespace alias_for_outerinner = outer::inner; diff --git a/test/manual/cedet/tests/testvarnames.java b/test/manual/cedet/tests/testvarnames.java new file mode 100644 index 00000000000..217a10d53e2 --- /dev/null +++ b/test/manual/cedet/tests/testvarnames.java @@ -0,0 +1,60 @@ +// testvarnames.java --- Semantic unit test for Java + +// Copyright (C) 2009-2019 Free Software Foundation, Inc. + +// Author: Eric M. Ludlam + +// This file is part of GNU Emacs. + +// GNU Emacs 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 3 of the License, or +// (at your option) any later version. + +// GNU Emacs 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 GNU Emacs. If not, see . + +package tests; + +/** + * + * + * Created: 02/17/14 + * + * @author Eric M. Ludlam + * @version + * @since + */ +public class testvarnames { + + public class varorclass { + public static long misclongvalue; + }; + + public static varorclass varoftypevarorclass = NULL; + + public static long varorclass = 1; + + public static long assignintovar = 1; + + public static varorclass classassign = NULL; + + static public void main(String [] args) { + + varorclass = assign// -1- + // #1# ( "assignintovar" ) + ; + + varoftypevarorclass = clas// -2- + // #2# ( "classassign" ) + + varoftypevarorclass.misc//-3- + // #3# ( "misclongvalue" ) + } + +} // testvarnames diff --git a/test/manual/cedet/tests/testwisent.wy b/test/manual/cedet/tests/testwisent.wy new file mode 100644 index 00000000000..07f8637a655 --- /dev/null +++ b/test/manual/cedet/tests/testwisent.wy @@ -0,0 +1,85 @@ +;; testwisent.wy --- unit test support file for semantic-utest-ia + +;; Copyright (C) 2008-2019 Free Software Foundation, Inc. + +;; Author: Eric M. Ludlam + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: +;; +;; Parser for nothing in particular mode + +%languagemode nothing-mode +%parsetable wisent-nothing-parser-tables +%keywordtable wisent-nothing-keywords +%tokentable wisent-nothing-tokens +%languagemode nothing-mode +%setupfunction wisent-nothing-default-setup + +%start goal + +;;; Punctuation +%type ;;syntax "\\(\\s.\\|\\s$\\|\\s'\\)+" matchdatatype string + +%token DOT "." +%token COMA "," +%token COLONCOLON "::" +%token COLON ":" +%token SEMICOLON ";" + +;;; KEYWORDS +%type + +%keyword COLONOSCOPY "colonoscopy" +%keyword SEMISOMETHING "semisomething" + +%% + +goal + ;; Misc + : COLON ;; -1- + ;; #1# ( "COLONCOLON" "COLON" "COLONOSCOPY" ) + | SEMI ;; -2- + ;; #2# ( "SEMI_useless_rule" "SEMICOLON" "SEMISOMETHING" ) + | thing ;; -3- + ;; #3# ( "thing_term_1" "thing_term_2" ) + ; + +SEMI_useless_rule + : + ; + +thing_term_1 + : + ; + +thing_term_2 + : + ; + +%% +(define-lex wisent-nothing-lexer + "Lexical analyzer to handle nothing in particular buffers." + ;; semantic-lex-newline + semantic-lex-ignore-whitespace + semantic-lex-ignore-newline + semantic-lex-ignore-comments + + semantic-lex-default-action + ) + +;; testwisent.wy ends here \ No newline at end of file -- cgit v1.2.1