Skip to content

Commit

Permalink
[tests] add test for custom target and macro com API limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Oct 6, 2023
1 parent 7074ea1 commit de6493f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/misc/projects/Issue11128/InitMacro.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import haxe.macro.Compiler;
import haxe.macro.Context;
import haxe.macro.Type;

class InitMacro {
static function setup() {
switch (Compiler.getConfiguration().platform) {
case CustomTarget("mylang"): {}
case _: throw "this shouldnt happen.";
}

Context.onAfterTyping(check);
}

static function check(types:Array<ModuleType>) {
for (m in types) {
switch (m) {
case TClassDecl(_.get() => c):
for (f in c.fields.get()) f.expr();

case _:
}
}
}
}
1 change: 1 addition & 0 deletions tests/misc/projects/Issue11128/Main2.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function main() {}
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue11128/compile5.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-main Main2
--custom-target mylang=out
--macro InitMacro.setup()
6 changes: 6 additions & 0 deletions tests/misc/projects/Issue11128/mylang/Init.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package mylang;

class Init {
public static function init() {
}
}

0 comments on commit de6493f

Please sign in to comment.