Main.hx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import sys.io.File;
  2. using StringTools;
  3. class Main {
  4. #if macro
  5. public static function init() {
  6. var pos = haxe.macro.Context.currentPos();
  7. haxe.macro.Context.onAfterInitMacros(() -> {
  8. haxe.macro.Context.defineType({
  9. pack: [],
  10. name: "TopLevelType",
  11. pos: pos,
  12. kind: TDStructure,
  13. fields: []
  14. });
  15. haxe.macro.Context.defineType({
  16. pack: ["foo", "bar"],
  17. name: "DefinedType",
  18. pos: pos,
  19. kind: TDStructure,
  20. fields: []
  21. });
  22. });
  23. }
  24. #else
  25. public static function main() {
  26. // Add generated modules as dependencies for Main
  27. var _:TopLevelType = {};
  28. var _:foo.bar.DefinedType = {};
  29. var lines = File.getContent("dump/eval/dependencies.dump").split("\n");
  30. lines = lines.map(l -> l.trim().replace("\\", "/"));
  31. inline function check(module:String) {
  32. var matches = Lambda.filter(lines, l -> l.contains(module));
  33. if (matches.length == 0)
  34. throw 'Cannot find $module in dependency dump';
  35. for (line in matches) {
  36. if (line.endsWith(":")) line = line.substr(0, line.length - 1);
  37. if (!line.endsWith('tests/misc/projects/Issue11852/$module')) {
  38. trace(module, line);
  39. throw 'Incorrect path generated for $module';
  40. }
  41. }
  42. }
  43. // Check generated path for macro generated modules
  44. check("TopLevelType_1_1");
  45. check("foo/bar/DefinedType_1_2");
  46. }
  47. #end
  48. }