Browse Source

add basic build macro display test

Simon Krajewski 9 years ago
parent
commit
eaa907bc80
1 changed files with 34 additions and 0 deletions
  1. 34 0
      tests/display/src/cases/BuildMacro.hx

+ 34 - 0
tests/display/src/cases/BuildMacro.hx

@@ -0,0 +1,34 @@
+package cases;
+
+class BuildMacro extends DisplayTestCase {
+	/**
+	class MyMacro {
+		macro static public function build():Array<haxe.macro.Expr.Field> {
+			var fields = haxe.macro.Context.getBuildFields();
+			return fields;
+		}
+	}
+
+	{-7-}typedef MyString = String{-8-};
+
+	#if !macro
+	@:build(cases.BuildMacro.MyMacro.build())
+	#end
+	class Main {
+		function te{-1-}st({-5-}na{-2-}me{-6-}:MySt{-3-}ring):MyStr{-4-}ing {
+			return {-9-}name{-10-};
+		}
+
+		static function main() { }
+	}
+	**/
+	function test1() {
+		eq("cases.MyString", type(pos(2)));
+		eq("cases.MyString", type(pos(3)));
+		eq("cases.MyString", type(pos(4)));
+		eq(range(7, 8), position(pos(3)));
+		eq(range(7, 8), position(pos(4)));
+		eq(range(5, 6), position(pos(2)));
+		arrayEq([range(9, 10)], usage(pos(10)));
+	}
+}