aboutsummaryrefslogtreecommitdiffstats
path: root/test/manual/cedet/tests/testusing.cpp
diff options
context:
space:
mode:
authorEric Ludlam2019-10-27 20:31:34 -0400
committerStefan Monnier2019-10-31 19:01:08 -0400
commit0f7163ab89cc6158dbb7a382b67da5ce200f42f1 (patch)
tree4109343b6a39d7955c6d4f6b0f2f7ec4b4606dda /test/manual/cedet/tests/testusing.cpp
parentfd1b720028064c2566ff4dcc3ad898346a0f6b77 (diff)
downloademacs-0f7163ab89cc6158dbb7a382b67da5ce200f42f1.tar.gz
emacs-0f7163ab89cc6158dbb7a382b67da5ce200f42f1.zip
* 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>
Diffstat (limited to 'test/manual/cedet/tests/testusing.cpp')
-rw-r--r--test/manual/cedet/tests/testusing.cpp265
1 files changed, 265 insertions, 0 deletions
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 @@
1// testusing.cpp --- semantic-ia-utest completion engine unit tests
2
3// Copyright (C) 2008-2019 Free Software Foundation, Inc.
4
5// Author: Eric M. Ludlam <zappo@gnu.org>
6
7// This file is part of GNU Emacs.
8
9// GNU Emacs is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13
14// GNU Emacs is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18
19// You should have received a copy of the GNU General Public License
20// along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
21
22
23#include <adstdio.h>
24
25#include <testusing.hh>
26
27namespace moose {
28
29 class MyClass;
30 class Point;
31
32 typedef MyClass snerk;
33}
34
35namespace moose {
36
37 class Point;
38 class MyClass;
39
40}
41
42namespace {
43
44 int global_variable = 0;
45
46};
47
48using moose::MyClass;
49
50void someFcn() {
51
52 MyClass f;
53
54 f.//-1-
55 ; //#1# ( "getVal" "setVal" )
56
57}
58
59// Code from Zhiqiu Kong
60
61namespace panda {
62
63 using namespace bread_name;
64
65 int func()
66 {
67 bread test;
68 test.//-2-
69 ;// #2# ( "geta" )
70 return 0;
71 }
72}
73
74namespace togglemoose {
75
76 MyOtherClass::testToggle1() { //^1^
77 // Impl for testToggle1
78 }
79}
80
81togglemoose::MyOtherClass::testToggle2() { //^3^
82 // Impl for testToggle2
83}
84
85using togglemoose;
86
87MyOtherClass::testToggle3() { //^3^
88 // Impl for testToggle3
89}
90
91// Local using statements and aliased types
92// Code from David Engster
93
94void func2()
95{
96 using namespace somestuff;
97 OneClass f;
98 f.//-3-
99 ; //#3# ( "aFunc" "anInt" )
100}
101
102void func3()
103{
104 using somestuff::OneClass;
105 OneClass f;
106 f.//-4-
107 ; //#4# ( "aFunc" "anInt" )
108}
109
110// Dereferencing alias types created through 'using' statements
111
112// Alias with fully qualified name
113void func4()
114{
115 otherstuff::OneClass f;
116 f. //-5-
117 ; //#5# ( "aFunc" "anInt" )
118}
119
120// Alias through namespace directive
121void func5()
122{
123 using namespace otherstuff;
124 OneClass f;
125 f. //-6-
126 ; //#6# ( "aFunc" "anInt" )
127}
128
129// Check name hiding
130void func6()
131{
132 using namespace morestuff;
133 OneClass f; // Alias for somestuff::OneClass
134 f. //-7-
135 ; //#7# ( "aFunc" "anInt" )
136 aStruct g; // This however is morestuff::aStruct !
137 g. //-8-
138 ; //#8# ( "anotherBar" "anotherFoo" )
139}
140
141// Alias of an alias
142// Currently doesn't work interactively for some reason.
143void func6()
144{
145 using namespace evenmorestuff;
146 OneClass f;
147 f. //-7-
148 ; //#7# ( "aFunc" "anInt" )
149}
150
151// Alias for struct in nested namespace, fully qualified
152void func7()
153{
154 outer::StructNested f;
155 f.//-8-
156 ; //#8# ( "one" "two" )
157}
158
159// Alias for nested namespace
160void func8()
161{
162 using namespace outerinner;
163 StructNested f;
164 AnotherStruct g;
165 f.//-9-
166 ; //#9# ( "one" "two" )
167 g.//-10-
168 ; //#10# ( "four" "three" )
169}
170
171// Check convetional namespace aliases
172// - fully qualified -
173void func9()
174{
175 alias_for_somestuff::OneClass c;
176 c.//-11-
177 ; //#11# ( "aFunc" "anInt" )
178 alias_for_outerinner::AnotherStruct s;
179 s. //-12-
180 ; //#12# ( "four" "three" )
181}
182
183// - unqualified -
184void func10()
185{
186 using namespace alias_for_somestuff;
187 OneClass c2;
188 c2.//-13-
189 ; //#13# ( "aFunc" "anInt" )
190 using namespace alias_for_outerinner;
191 AnotherStruct s2;
192 s2.//-14-
193 ; //#14# ( "four" "three" )
194}
195
196// Completion on namespace aliases
197void func11()
198{
199 alias_for_somestuff:://-15-
200 ; //#15# ( "OneClass" "aStruct")
201 alias_for_outerinner:://-16-
202 ; //#16# ( "AnotherStruct" "StructNested" )
203}
204
205// make sure unfound using statements don't crash stuff.
206using something::cantbe::Found;
207
208void unfoundfunc()
209{
210 NotFound notfound; // Variable can't be found.
211
212 notfound.//-17-
213 ; //#17# ( ) Nothing here since this is an undefined class
214
215}
216
217// Using statements can depend on previous ones...
218
219void acc_using()
220{
221 using namespace outer;
222 // This is effectively like 'using namespace outer::inner'
223 using namespace inner;
224
225 StructNested sn;
226 sn.//-18-
227 ; //#18# ( "one" "two" )
228}
229
230// Check the same outside of function scope
231
232using namespace outer;
233using namespace inner;
234
235void acc_using2()
236{
237 StructNested sn;
238 sn.//-19-
239 ; //#19# ( "one" "two" )
240}
241
242// Check if scope gets correctly generated, i.e., without us providing any
243// hints in the form of an existing type
244
245void check_scope()
246{
247 using namespace first;
248 AAA//-20-
249 ; //#20# ( "AAA1" "AAA2" )
250}
251
252void check_scope2()
253{
254 using namespace third;
255 AAA//-21-
256 ; //#21# ( "AAA1" "AAA2" "AAA3" )
257}
258
259// Make sure this also works not only in functions
260
261namespace check_scope3 {
262 using namespace first;
263 AAA//-22-
264 ; //#22# ( "AAA1" "AAA2" )
265}