Explorar o código

[tests] add failing test

Rudy Ges hai 7 meses
pai
achega
03283bf59c

+ 38 - 0
tests/server/src/cases/issues/Issue11995.hx

@@ -0,0 +1,38 @@
+package cases.issues;
+
+import haxe.display.Diagnostic;
+import utest.Async;
+
+class Issue11995 extends TestCase {
+	@:async
+	@:variant("WithInvalidation", true)
+	@:variant("WithoutInvalidation", false)
+	function test(async:Async, invalidate:Bool) {
+		var content = getTemplate("issues/Issue11995/Main.hx");
+		var transform = Markers.parse(content);
+		vfs.putContent("Main.hx", transform.source);
+		vfs.putContent("Macro.hx", getTemplate("issues/Issue11995/Macro.hx"));
+		var args = ["Main"];
+		runHaxe(args, () -> {
+			assertSuccess();
+
+			function doTest() {
+				runHaxeJsonCb(args, DisplayMethods.Hover, {file: new FsPath("Main.hx"), offset: transform.offset(1)}, (res) -> {
+					// No error during hover
+					Assert.pass();
+				}, () -> {
+					assertSuccess();
+					async.done();
+				});
+			}
+
+			if (invalidate) {
+				runHaxeJson(args, ServerMethods.Invalidate, {file: new FsPath("Main.hx")}, () -> {
+					doTest();
+				});
+			} else {
+				doTest();
+			}
+		});
+	}
+}

+ 20 - 0
tests/server/test/templates/issues/Issue11995/Macro.hx

@@ -0,0 +1,20 @@
+import haxe.macro.Context;
+using Lambda;
+
+class Macro {
+	public static function bar() {
+		var fields = Context.getBuildFields();
+
+		switch fields.find(f -> f.name == "foo").kind {
+			case FFun(f):
+				f.expr = macro {
+					var baz:String = "hello";
+					${f.expr}
+				};
+
+			default: throw "assert";
+		}
+
+		return fields;
+	}
+}

+ 6 - 0
tests/server/test/templates/issues/Issue11995/Main.hx

@@ -0,0 +1,6 @@
+@:build(Macro.bar())
+class Main {
+	static function foo() {
+		trace(ba{-1-}z);
+	}
+}