Main.hx 603 B

12345678910111213141516171819202122
  1. import haxe.macro.Context;
  2. import haxe.macro.PositionTools;
  3. class Main {
  4. #if !macro
  5. static function main(){
  6. test();
  7. }
  8. #end
  9. static macro function test() {
  10. var pos = Context.makePosition({min: 20, max: 23, file: 'my_template.mtt' });
  11. var range = PositionTools.toLocation(pos).range;
  12. if(range.start.line != range.end.line || range.end.line != 2) {
  13. Context.fatalError('Invalid position', pos);
  14. }
  15. Context.parse('foo', pos);
  16. if(range.start.line != range.end.line || range.end.line != 2) {
  17. Context.fatalError('Invalid position after Context.parse', pos);
  18. }
  19. return macro null;
  20. }
  21. }