|
@@ -32,7 +32,91 @@ class Toplevel extends DisplayTestCase {
|
|
|
eq(true, hasToplevel(toplevel2, "local", "a"));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ class Main {
|
|
|
+ static var myField;
|
|
|
+ static function main() {
|
|
|
+ var a:{-1-}
|
|
|
+ **/
|
|
|
+ function testTypeCompletionLocal() {
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Main"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ eq(false, hasToplevel(typesCompletion, "static", "myField"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ class Main {
|
|
|
+ var a:{-1-}
|
|
|
+ **/
|
|
|
+ function testTypeCompletionField() {
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Main"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ class Main {
|
|
|
+ static function f(a:{-1-})
|
|
|
+ **/
|
|
|
+ function testTypeCompletionArgument() {
|
|
|
+ // TODO: this currently doesn't work if there's no closing paren for function arguments
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Main"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ var a = function(a:{-1-}
|
|
|
+ **/
|
|
|
+ @:funcCode function testTypeCompletionArgumentLocal() {
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ import {-1-}
|
|
|
+ **/
|
|
|
+ function testTypeCompletionArgumentImport() {
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ using {-1-}
|
|
|
+ **/
|
|
|
+ function testTypeCompletionArgumentUsing() {
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ class C extends {-1-} {
|
|
|
+ **/
|
|
|
+ function testTypeCompletionArgumentExtends() {
|
|
|
+ // TODO: this currently doesn't work if there's no token after extends
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ class C implements {-1-} {
|
|
|
+ **/
|
|
|
+ function testTypeCompletionArgumentImplements() {
|
|
|
+ // TODO: this currently doesn't work if there's no token after implements
|
|
|
+ var typesCompletion = toplevel(pos(1));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "type", "Array"));
|
|
|
+ eq(true, hasToplevel(typesCompletion, "package", "haxe"));
|
|
|
+ }
|
|
|
+
|
|
|
static function hasToplevel(a:Array<ToplevelElement>, kind:String, name:String):Bool {
|
|
|
return a.exists(function(t) return t.kind == kind && t.name == name);
|
|
|
}
|
|
|
-}
|
|
|
+}
|