Skip to content

Commit

Permalink
[tests] Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Jan 21, 2025
1 parent 709c0d7 commit b908b5e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/misc/projects/Issue11852/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys.io.File;

class Main {
#if macro
public static function init() {
var pos = haxe.macro.Context.currentPos();

haxe.macro.Context.onAfterInitMacros(() -> {
haxe.macro.Context.defineType({
pack: [],
name: "TopLevelType",
pos: pos,
kind: TDStructure,
fields: []
});

haxe.macro.Context.defineType({
pack: ["foo", "bar"],
name: "DefinedType",
pos: pos,
kind: TDStructure,
fields: []
});
});
}
#else
public static function main() {
// Add generated modules as dependencies for Main
var _:TopLevelType = {};
var _:foo.bar.DefinedType = {};

var lines = File.getContent("dump/eval/dependencies.dump").split("\n");
lines = lines.map(l -> StringTools.replace(l, "\\", "/"));
inline function check(module:String) {
var line = Lambda.filter(lines, l -> StringTools.endsWith(l, module)).shift();

if (line == null)
throw 'Cannot find $module in dependency dump';

if (!StringTools.endsWith(line, 'tests/misc/projects/Issue11852/$module')) {
trace(module, line);
throw 'Incorrect path generated for $module';
}
}

// Check generated path for macro generated modules
check("TopLevelType_1_1");
check("foo/bar/DefinedType_1_2");
}
#end
}
4 changes: 4 additions & 0 deletions tests/misc/projects/Issue11852/compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--macro Main.init()
-main Main
-D dump-dependencies
--interp

0 comments on commit b908b5e

Please sign in to comment.