//------------------------------------------------------------------------------ // CLING - the C++ LLVM-based InterpreterG :) // // This file is dual-licensed: you can choose to license it under the University // of Illinois Open Source License or the GNU Lesser General Public License. See // LICENSE.TXT for details. //------------------------------------------------------------------------------ // RUN: cat %s | %cling | FileCheck %s #include "cling/Interpreter/Interpreter.h" #include #include std::vector completions; std::string input = "gCling"; size_t point = 3; gCling->codeComplete(input, point, completions); //completions // globalVar expected globalVariable int globalVariable; completions.clear(); input = "globalVariable" point = 7; gCling->codeComplete(input, point, completions); //CHECK: (std::basic_string &) "globalVariable" .rawInput 1 struct MyStruct { MyStruct() {} MyStruct anOverload(int) { return MyStruct(); } MyStruct anOverload(float) { return MyStruct(); } }; .rawInput 0 // MyStr m; completions.clear(); input = "MyStruct" point = 5; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "MyStruct" } MyStruct m; // m. completions.clear(); input = "m."; point = 2; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "[#MyStruct#]anOverload(<#int#>)", "[#MyStruct#]anOverload(<#float#>)", "MyStruct::", "[#MyStruct &#]operator=(<#const MyStruct &#>)", "[#MyStruct &#]operator=(<#MyStruct &&#>)" } // anK(12) completions.clear(); input = "m.an"; point = 4; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "[#MyStruct#]anOverload(<#int#>)", "[#MyStruct#]anOverload(<#float#>)" } .rawInput 1 extern "C" int printf(const char* fmt, ...); namespace MyNamespace { class MyClass { public: MyClass() { printf("MyClass constructor called!\n"); } }; void f() { printf("Function f in namespace MyNamespace called!\n"); } } .rawInput 0 //My // expected MyNamespace, MyClass completions.clear(); input = "My"; point = 2; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "MyNamespace::", "MyStruct" } //MyNames // expected MyNamespace //expected MyClass, f completions.clear(); input = "MyNames"; point = 7; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "MyNamespace::" } //MyNames // expected MyNamespace //expected MyClass, f completions.clear(); input = "MyNamespace::"; point = 13; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "[#void#]f()", "MyClass" } //MyNamespace::MyC // expected MyClass completions.clear(); input = "MyNamespace::MyC"; point = 16; gCling->codeComplete(input, point, completions); completions //CHECK: (std::vector &) { "MyClass" }