From 892901b65f72070cbf36cb56d5cc50290dd348a4 Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Tue, 18 Jun 2024 10:37:43 +0200 Subject: [PATCH] [tests] Add test for 11695 --- tests/server/src/cases/issues/Issue11695.hx | 39 +++++++++++++++++++ .../templates/issues/Issue11695/Macro1.hx | 1 + .../templates/issues/Issue11695/Macro2.hx | 1 + .../test/templates/issues/Issue11695/Main.hx | 3 ++ 4 files changed, 44 insertions(+) create mode 100644 tests/server/src/cases/issues/Issue11695.hx create mode 100644 tests/server/test/templates/issues/Issue11695/Macro1.hx create mode 100644 tests/server/test/templates/issues/Issue11695/Macro2.hx create mode 100644 tests/server/test/templates/issues/Issue11695/Main.hx diff --git a/tests/server/src/cases/issues/Issue11695.hx b/tests/server/src/cases/issues/Issue11695.hx new file mode 100644 index 00000000000..54eb3fb0622 --- /dev/null +++ b/tests/server/src/cases/issues/Issue11695.hx @@ -0,0 +1,39 @@ +package cases.issues; + +class Issue11695 extends TestCase { + function test(_) { + vfs.putContent("Main.hx", getTemplate("issues/Issue11695/Main.hx")); + vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro1.hx")); + var args = ["-main", "Main", "--interp"]; + runHaxe(args); + assertHasPrint("Macro.hx:1: before"); + + // Note: this is needed because modification time is currently checked with second precision + Sys.sleep(1); + + vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro2.hx")); + runHaxeJsonCb(args, DisplayMethods.Diagnostics, {file: new FsPath("Macro.hx")}, res -> { + Assert.equals(0, res.length); + }); + + runHaxe(args); + assertHasPrint("Macro.hx:1: after"); + } + + function testLegacyDiagnostics(_) { + vfs.putContent("Main.hx", getTemplate("issues/Issue11695/Main.hx")); + vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro1.hx")); + var args = ["-main", "Main", "--interp"]; + runHaxe(args); + assertHasPrint("Macro.hx:1: before"); + + // Note: this is needed because modification time is currently checked with second precision + Sys.sleep(1); + + vfs.putContent("Macro.hx", getTemplate("issues/Issue11695/Macro2.hx")); + runHaxe(args.concat(["--display", "Macro.hx@0@diagnostics"])); + + runHaxe(args); + assertHasPrint("Macro.hx:1: after"); + } +} diff --git a/tests/server/test/templates/issues/Issue11695/Macro1.hx b/tests/server/test/templates/issues/Issue11695/Macro1.hx new file mode 100644 index 00000000000..5adc7114e93 --- /dev/null +++ b/tests/server/test/templates/issues/Issue11695/Macro1.hx @@ -0,0 +1 @@ +macro function test() return macro trace("before"); diff --git a/tests/server/test/templates/issues/Issue11695/Macro2.hx b/tests/server/test/templates/issues/Issue11695/Macro2.hx new file mode 100644 index 00000000000..fc6a9dbb6a8 --- /dev/null +++ b/tests/server/test/templates/issues/Issue11695/Macro2.hx @@ -0,0 +1 @@ +macro function test() return macro trace("after"); diff --git a/tests/server/test/templates/issues/Issue11695/Main.hx b/tests/server/test/templates/issues/Issue11695/Main.hx new file mode 100644 index 00000000000..8460064b0d2 --- /dev/null +++ b/tests/server/test/templates/issues/Issue11695/Main.hx @@ -0,0 +1,3 @@ +function main() { + Macro.test(); +}