Просмотр исходного кода

[display] add a test for keyword completion in import.hx

Jens Fischer 6 лет назад
Родитель
Сommit
ca0eab7ebd

+ 1 - 0
tests/display/.gitignore

@@ -0,0 +1 @@
+dump

+ 1 - 6
tests/display/.vscode/launch.json

@@ -1,15 +1,10 @@
 {
-	// Use IntelliSense to learn about possible attributes.
-	// Hover to view descriptions of existing attributes.
-	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 	"version": "0.2.0",
 	"configurations": [
 		{
 			"name": "Haxe-eval",
 			"type": "haxe-eval",
-			"request": "launch",
-			"cwd": "${workspaceRoot}",
-			"hxml": "${workspaceRoot}/build.hxml"
+			"request": "launch"
 		}
 	]
 }

+ 15 - 1
tests/display/src/Macro.hx

@@ -33,8 +33,19 @@ class Macro {
 				return "";
 			});
 			var markers = markers.length > 0 ? macro $a{markers} : macro new Map();
+			var filename = Context.getPosInfos(c.pos).file;
+			for (meta in field.meta) {
+				if (meta.name == ":filename") {
+					switch (meta.params[0].expr) {
+						case EConst(CString(s)):
+							filename = Path.directory(filename) + "/" + s;
+						case _:
+							throw "String expected";
+					}
+				}
+			}
 			testCases.push(macro function() {
-				ctx = new DisplayTestContext($v{Context.getPosInfos(c.pos).file}, $v{field.name}, $v{src}, $markers);
+				ctx = new DisplayTestContext($v{filename}, $v{field.name}, $v{src}, $markers);
 				$i{field.name}();
 			});
 		}
@@ -60,6 +71,9 @@ class Macro {
 				if (singleCase != null && !file.endsWith(singleCase + ".hx")) {
 					continue;
 				}
+				if (file.endsWith("import.hx")) {
+					continue;
+				}
 				var p = new haxe.io.Path(file);
 				if (p.ext == "hx") {
 					var tp = {pack: pack, name: p.file};

+ 13 - 0
tests/display/src/cases/Issue7053.hx

@@ -144,4 +144,17 @@ class Issue7053 extends DisplayTestCase {
 			eq(false, hasField(fields, unexpected, null, "keyword"));
 		}
 	}
+
+	/**
+	{-1-}
+	**/
+	@:filename("import.hx")
+	function testInImportHx() {
+		var keywords = toplevel(pos(1));
+		var expectedKeywords = ["import", "using"];
+		for (expected in expectedKeywords) {
+			eq(true, hasField(keywords, expected, null, "keyword"));
+		}
+		eq(expectedKeywords.length, keywords.length);
+	}
 }

+ 3 - 0
tests/display/src/cases/import.hx

@@ -0,0 +1,3 @@
+package cases;
+
+// this is stupid