Skip to content

Commit 2ad8f5e

Browse files
committed
[tests] add failing test
1 parent ed58a64 commit 2ad8f5e

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package cases.issues;
2+
3+
import haxe.display.Diagnostic;
4+
import utest.Async;
5+
6+
class Issue11995 extends TestCase {
7+
@:async
8+
@:variant("WithInvalidation", true)
9+
@:variant("WithoutInvalidation", false)
10+
function test(async:Async, invalidate:Bool) {
11+
var content = getTemplate("issues/Issue11995/Main.hx");
12+
var transform = Markers.parse(content);
13+
vfs.putContent("Main.hx", transform.source);
14+
vfs.putContent("Macro.hx", getTemplate("issues/Issue11995/Macro.hx"));
15+
var args = ["Main"];
16+
runHaxe(args, () -> {
17+
assertSuccess();
18+
19+
function doTest() {
20+
runHaxeJsonCb(args, DisplayMethods.Hover, {file: new FsPath("Main.hx"), offset: transform.offset(1)}, (res) -> {
21+
// No error during hover
22+
Assert.pass();
23+
}, () -> {
24+
assertSuccess();
25+
async.done();
26+
});
27+
}
28+
29+
if (invalidate) {
30+
runHaxeJson(args, ServerMethods.Invalidate, {file: new FsPath("Main.hx")}, () -> {
31+
doTest();
32+
});
33+
} else {
34+
doTest();
35+
}
36+
});
37+
}
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import haxe.macro.Context;
2+
using Lambda;
3+
4+
class Macro {
5+
public static function bar() {
6+
var fields = Context.getBuildFields();
7+
8+
switch fields.find(f -> f.name == "foo").kind {
9+
case FFun(f):
10+
f.expr = macro {
11+
var baz:String = "hello";
12+
${f.expr}
13+
};
14+
15+
default: throw "assert";
16+
}
17+
18+
return fields;
19+
}
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@:build(Macro.bar())
2+
class Main {
3+
static function foo() {
4+
trace(ba{-1-}z);
5+
}
6+
}

0 commit comments

Comments
 (0)