Browse Source

use real classes for issue tests so local types can be defined

Simon Krajewski 11 years ago
parent
commit
6f963351a9

+ 1 - 1
tests/unit/Test.hx

@@ -270,7 +270,6 @@ class Test #if swf_mark implements mt.Protect #end {
 			new TestMatch(),
 			#end
 			new TestSpecification(),
-			new unit.issues.TestIssues(),
 			#if cs
 			new TestCSharp(),
 			#end
@@ -292,6 +291,7 @@ class Test #if swf_mark implements mt.Protect #end {
 			//new TestUnspecified(),
 			//new TestRemoting(),
 		];
+		TestIssues.addIssueClasses();
 		var current = null;
 		#if (!fail_eager)
 		try

+ 20 - 0
tests/unit/TestIssues.hx

@@ -0,0 +1,20 @@
+package unit;
+
+using StringTools;
+
+class TestIssues {
+	macro static public function addIssueClasses() {
+		var dir = sys.FileSystem.readDirectory("issues");
+		var el = [];
+		function add(className:String) {
+			el.push(macro classes.push(new unit.issues.$className()));
+		}
+		for (file in dir) {
+			if (!file.endsWith(".hx")) {
+				continue;
+			}
+			add(file.substr(0, -3));
+		}
+		return macro $b{el};
+	}
+}

+ 0 - 9
tests/unit/issues/2623.issue.hx

@@ -1,9 +0,0 @@
-var v1:E1 = A(1);
-var v2 = A("foo");
-var v3:E1 = B;
-var v4 = B;
-
-Type.getEnum(v1) == E1;
-Type.getEnum(v2) == E2;
-Type.getEnum(v3) == E1;
-Type.getEnum(v4) == E2;

+ 25 - 0
tests/unit/issues/Issue2623.hx

@@ -0,0 +1,25 @@
+package unit.issues;
+
+enum E1 {
+	A(i:Int);
+	B;
+}
+
+enum E2 {
+	A(s:String);
+	B;
+}
+
+class Issue2623 extends unit.Test {
+	public function test() {
+		var v1:E1 = A(1);
+		var v2 = A("foo");
+		var v3:E1 = B;
+		var v4 = B;
+
+		eq(Type.getEnum(v1), E1);
+		eq(Type.getEnum(v2), E2);
+		eq(Type.getEnum(v3), E1);
+		eq(Type.getEnum(v4), E2);
+	}
+}

+ 0 - 18
tests/unit/issues/TestIssues.hx

@@ -1,18 +0,0 @@
-package unit.issues;
-
-enum E1 {
-	A(i:Int);
-	B;
-}
-
-enum E2 {
-	A(s:String);
-	B;
-}
-
-#if !macro
-@:build(unit.UnitBuilder.build("issues", ".issue.hx"))
-#end
-class TestIssues extends Test {
-
-}