Skip to content

Commit 689c3ec

Browse files
CristinaCristescuAxel-Naumann
authored andcommitted
Cling tab comp minimal test.
1 parent a2df77e commit 689c3ec

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

test/Prompt/TabCompletion.C

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
//------------------------------------------------------------------------------
2+
// CLING - the C++ LLVM-based InterpreterG :)
3+
//
4+
// This file is dual-licensed: you can choose to license it under the University
5+
// of Illinois Open Source License or the GNU Lesser General Public License. See
6+
// LICENSE.TXT for details.
7+
//------------------------------------------------------------------------------
8+
9+
// RUN: cat %s | %cling | FileCheck %s
10+
11+
#include "cling/Interpreter/Interpreter.h"
12+
#include <vector>
13+
#include <string>
14+
15+
std::vector<std::string> completions;
16+
std::string input = "gCling";
17+
size_t point = 3;
18+
gCling->codeComplete(input, point, completions);
19+
//completions
20+
21+
// globalVar<TAB> expected globalVariable
22+
int globalVariable;
23+
completions.clear();
24+
input = "globalVariable"
25+
point = 7;
26+
gCling->codeComplete(input, point, completions); //CHECK: (std::basic_string &) "globalVariable"
27+
28+
29+
30+
.rawInput 1
31+
32+
struct MyStruct {
33+
MyStruct() {}
34+
MyStruct anOverload(int) { return MyStruct(); }
35+
MyStruct anOverload(float) { return MyStruct(); }
36+
};
37+
38+
.rawInput 0
39+
40+
// MyStr<TAB> m;
41+
completions.clear();
42+
input = "MyStruct"
43+
point = 5;
44+
gCling->codeComplete(input, point, completions);
45+
completions //CHECK: (std::vector<std::string> &) { "MyStruct" }
46+
47+
MyStruct m;
48+
// m.<TAB>
49+
completions.clear();
50+
input = "m.";
51+
point = 2;
52+
gCling->codeComplete(input, point, completions);
53+
completions //CHECK: (std::vector<std::string> &) { "[#MyStruct#]anOverload(<#int#>)", "[#MyStruct#]anOverload(<#float#>)", "MyStruct::", "[#MyStruct &#]operator=(<#const MyStruct &#>)", "[#MyStruct &#]operator=(<#MyStruct &&#>)" }
54+
55+
// an<TAB>K(12)
56+
completions.clear();
57+
input = "m.an";
58+
point = 4;
59+
gCling->codeComplete(input, point, completions);
60+
completions //CHECK: (std::vector<std::string> &) { "[#MyStruct#]anOverload(<#int#>)", "[#MyStruct#]anOverload(<#float#>)" }
61+
62+
63+
64+
.rawInput 1
65+
66+
extern "C" int printf(const char* fmt, ...);
67+
68+
namespace MyNamespace {
69+
class MyClass {
70+
public:
71+
MyClass() { printf("MyClass constructor called!\n"); }
72+
};
73+
74+
void f() {
75+
printf("Function f in namespace MyNamespace called!\n");
76+
}
77+
}
78+
79+
.rawInput 0
80+
81+
//My<TAB> // expected MyNamespace, MyClass
82+
completions.clear();
83+
input = "My";
84+
point = 2;
85+
gCling->codeComplete(input, point, completions);
86+
completions //CHECK: (std::vector<std::string> &) { "MyNamespace::", "MyStruct" }
87+
88+
//MyNames<TAB> // expected MyNamespace //expected MyClass, f
89+
completions.clear();
90+
input = "MyNames";
91+
point = 7;
92+
gCling->codeComplete(input, point, completions);
93+
completions //CHECK: (std::vector<std::string> &) { "MyNamespace::" }
94+
95+
//MyNames<TAB> // expected MyNamespace //expected MyClass, f
96+
completions.clear();
97+
input = "MyNamespace::";
98+
point = 13;
99+
gCling->codeComplete(input, point, completions);
100+
completions //CHECK: (std::vector<std::string> &) { "[#void#]f()", "MyClass" }
101+
102+
//MyNamespace::MyC<TAB> // expected MyClass
103+
completions.clear();
104+
input = "MyNamespace::MyC";
105+
point = 16;
106+
gCling->codeComplete(input, point, completions);
107+
completions //CHECK: (std::vector<std::string> &) { "MyClass" }

0 commit comments

Comments
 (0)