Commit 0f7163ab authored by Eric Ludlam's avatar Eric Ludlam Committed by Stefan Monnier

* 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 <zappo@gnu.org>
parent fd1b7200
# 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
;; test.srt --- unit test support file for semantic-utest-ia
;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; 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 <https://www.gnu.org/licenses/>.
;;
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"
----
{{<A:cla}} -1-
}} #1# ( "class" "classic" )
{{^}}
{{/A}}
----
;; This is a bad hack - In order for the text to parse, but also get a completion
;; monicker into the right spot, we need to pretend a comment is the same as the
;; escape_end.
;; Local variables:
;; comment-start-skip: "}}"
;; End:
\input texinfo
@setfilename test.info
@set TITLE TEST
@set AUTHOR Eric Ludlam
@settitle @value{TITLE}
@ifinfo
@format
START-INFO-DIR-ENTRY
* test: (test). TEST
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@titlepage
@sp 10
@center @titlefont{test}
@vskip 0pt plus 1 fill
Copyright @copyright{} 2015 Eric Ludlam
@end titlepage
@node Top
@top @value{TITLE}
This is a simple manual filled with stuff that should test completion in texinfo mode.
@m@c -1-
@c #1# ( "@majorheading" "@macro" "@menu" "@multitable" )
@menu
* Index::
@end menu
@node Index
@chapter Index
@contents
@bye
// testlocalvars.java --- Semantic unit test for Java
// Copyright (C) 2009-2019 Free Software Foundation, Inc.
// Author: Eric M. Ludlam <zappo@gnu.org>
// 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 <https://www.gnu.org/licenses/>.
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")
}
// teststruct.cpp --- semantic-ia-utest completion engine unit tests
// Copyright (C) 2008-2019 Free Software Foundation, Inc.
// Author: Eric M. Ludlam <zappo@gnu.org>
// 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 <https://www.gnu.org/licenses/>.
// Note: initially provided by 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")
}
// testtemplates.cpp --- semantic-ia-utest completion engine unit tests
// Copyright (C) 2008-2019 Free Software Foundation, Inc.
// Author: Eric M. Ludlam <zappo@gnu.org>
// 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 <https://www.gnu.org/licenses/>.
// TODO - this probably means can't be part of emacs, as I don't know who this guy is.
// 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
;
}
// More Namespace Magic using member constants.
template<typename T>
struct isFooLike {
static const bool value = false;
};
template <>
struct isFooLike<int> {
static const bool value = true;
};
template <typename T, bool isFoo>
class A {
public:
A();
void foo() {};
};
template <typename T>
class FooFour : public A<T, isPodLike<T>::value> {
public:
bool bar() {}
};
int main2() {
FooFour<int> ff;
ff.// - 9- @ TODO - bring over patch from SF
; // #9# ( "bar" "foo" );
}
// testusing.cpp --- semantic-ia-utest completion engine unit tests
// Copyright (C) 2008-2019 Free Software Foundation, Inc.
// Author: Eric M. Ludlam <zappo@gnu.org>
// 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 <https://www.gnu.org/licenses/>.
#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;
}
}
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