comparison test/cedet/tests/testusing.cpp @ 104494:e480034314ce

Add Semantic unit tests.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 20 Sep 2009 04:00:13 +0000
parents
children 7f4c7f5c0eba
comparison
equal deleted inserted replaced
104493:a4e1a12c8b97 104494:e480034314ce
1 // Test using statements in C++
2
3 #include <adstdio.h>
4
5 #include <testusing.hh>
6
7 namespace moose {
8
9 class MyClass;
10 class Point;
11
12 typedef MyClass snerk;
13 }
14
15 namespace moose {
16
17 class Point;
18 class MyClass;
19
20 }
21
22 namespace {
23
24 int global_variable = 0;
25
26 };
27
28 using moose::MyClass;
29
30 void someFcn() {
31
32 MyClass f;
33
34 f.//-1-
35 ; //#1# ( "getVal" "setVal" )
36
37 }
38
39 // Code from Zhiqiu Kong
40
41 namespace panda {
42
43 using namespace bread_name;
44
45 int func()
46 {
47 bread test;
48 test.//-2-
49 ;// #2# ( "geta" )
50 return 0;
51 }
52 }
53
54 // Local using statements and aliased types
55 // Code from David Engster
56
57 void func2()
58 {
59 using namespace somestuff;
60 OneClass f;
61 f.//-3-
62 ; //#3# ( "aFunc" "anInt" )
63 }
64
65 void func3()
66 {
67 using somestuff::OneClass;
68 OneClass f;
69 f.//-4-
70 ; //#4# ( "aFunc" "anInt" )
71 }
72
73 // Dereferencing alias types created through 'using' statements
74
75 // Alias with fully qualified name
76 void func4()
77 {
78 otherstuff::OneClass f;
79 f. //-5-
80 ; //#5# ( "aFunc" "anInt" )
81 }
82
83 // Alias through namespace directive
84 void func5()
85 {
86 using namespace otherstuff;
87 OneClass f;
88 f. //-6-
89 ; //#6# ( "aFunc" "anInt" )
90 }
91
92 // Check name hiding
93 void func6()
94 {
95 using namespace morestuff;
96 OneClass f; // Alias for somestuff::OneClass
97 f. //-7-
98 ; //#7# ( "aFunc" "anInt" )
99 aStruct g; // This however is morestuff::aStruct !
100 g. //-8-
101 ; //#8# ( "anotherBar" "anotherFoo" )
102 }
103
104 // Alias of an alias
105 // Currently doesn't work interactively for some reason.
106 void func6()
107 {
108 using namespace evenmorestuff;
109 OneClass f;
110 f. //-7-
111 ; //#7# ( "aFunc" "anInt" )
112 }
113
114 // Alias for struct in nested namespace, fully qualified
115 void func7()
116 {
117 outer::StructNested f;
118 f.//-8-
119 ; //#8# ( "one" "two" )
120 }
121
122 // Alias for nested namespace
123 void func8()
124 {
125 using namespace outerinner;
126 StructNested f;
127 AnotherStruct g;
128 f.//-9-
129 ; //#9# ( "one" "two" )
130 g.//-10-
131 ; //#10# ( "four" "three" )
132 }