Main.hx 440 B

123456789101112131415161718
  1. class Main {
  2. static function test() {
  3. var t = haxe.macro.Context.getType("A");
  4. function fail(msg) {
  5. Sys.println(msg);
  6. Sys.exit(1);
  7. }
  8. switch (t) {
  9. case TAbstract(a, _):
  10. var hasTestMeta = Lambda.exists(a.get().impl.get().meta.get(), function(m) return m.name == ":test");
  11. if (!hasTestMeta) {
  12. fail("Abstract implementation class has no @:test metadata");
  13. }
  14. case _:
  15. fail("Should be abstract");
  16. }
  17. }
  18. }