Browse Source

use an inline function for test counting so we can add some debugging

Simon Krajewski 10 years ago
parent
commit
600953cdb4
1 changed files with 21 additions and 12 deletions
  1. 21 12
      tests/unit/src/unit/Test.hx

+ 21 - 12
tests/unit/src/unit/Test.hx

@@ -10,8 +10,15 @@ class Test #if swf_mark implements mt.Protect #end {
 	public function new() {
 	public function new() {
 	}
 	}
 
 
+	static var out = sys.io.File.write("debug.txt", false);
+
+	static inline function incrCount(?pos:haxe.PosInfos) {
+		++count;
+		//out.writeString(pos.methodName +":" +pos.lineNumber + "\n");
+	}
+
 	function eq<T>( v : T, v2 : T, ?pos ) {
 	function eq<T>( v : T, v2 : T, ?pos ) {
-		count++;
+		incrCount(pos);
 		if( v != v2 ) {
 		if( v != v2 ) {
 			report(Std.string(v)+" should be "+Std.string(v2),pos);
 			report(Std.string(v)+" should be "+Std.string(v2),pos);
 			success = false;
 			success = false;
@@ -19,7 +26,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function feq( v : Float, v2 : Float, ?pos ) {
 	function feq( v : Float, v2 : Float, ?pos ) {
-		count++;
+		incrCount(pos);
 		if (!Math.isFinite(v) || !Math.isFinite(v2))
 		if (!Math.isFinite(v) || !Math.isFinite(v2))
 			eq(v, v2, pos);
 			eq(v, v2, pos);
 		else if ( Math.abs(v - v2) > 1e-10 ) {
 		else if ( Math.abs(v - v2) > 1e-10 ) {
@@ -41,7 +48,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function exc( f : Void -> Void, ?pos ) {
 	function exc( f : Void -> Void, ?pos ) {
-		count++;
+		incrCount(pos);
 		try {
 		try {
 			f();
 			f();
 			report("No exception occured",pos);
 			report("No exception occured",pos);
@@ -51,7 +58,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function unspec( f : Void -> Void, ?pos ) {
 	function unspec( f : Void -> Void, ?pos ) {
-		count++;
+		incrCount(pos);
 		try {
 		try {
 			f();
 			f();
 		} catch( e : Dynamic ) {
 		} catch( e : Dynamic ) {
@@ -59,7 +66,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function allow<T>( v : T, values : Array<T>, ?pos ) {
 	function allow<T>( v : T, values : Array<T>, ?pos ) {
-		count++;
+		incrCount(pos);
 		for( v2 in values )
 		for( v2 in values )
 			if( v == v2 )
 			if( v == v2 )
 				return;
 				return;
@@ -68,7 +75,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function hf(c:Class<Dynamic>, n:String, ?pos:haxe.PosInfos) {
 	function hf(c:Class<Dynamic>, n:String, ?pos:haxe.PosInfos) {
-		Test.count++;
+		Test.incrCount(pos);
 		if (!Lambda.has(Type.getInstanceFields(c), n)) {
 		if (!Lambda.has(Type.getInstanceFields(c), n)) {
 			Test.report(Type.getClassName(c) + " should have member field " +n, pos);
 			Test.report(Type.getClassName(c) + " should have member field " +n, pos);
 			success = false;
 			success = false;
@@ -76,7 +83,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function nhf(c:Class<Dynamic>, n:String, ?pos:haxe.PosInfos) {
 	function nhf(c:Class<Dynamic>, n:String, ?pos:haxe.PosInfos) {
-		Test.count++;
+		Test.incrCount(pos);
 		if (Lambda.has(Type.getInstanceFields(c), n)) {
 		if (Lambda.has(Type.getInstanceFields(c), n)) {
 			Test.report(Type.getClassName(c) + " should not have member field " +n, pos);
 			Test.report(Type.getClassName(c) + " should not have member field " +n, pos);
 			success = false;
 			success = false;
@@ -84,7 +91,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function hsf(c:Class<Dynamic> , n:String, ?pos:haxe.PosInfos) {
 	function hsf(c:Class<Dynamic> , n:String, ?pos:haxe.PosInfos) {
-		Test.count++;
+		Test.incrCount(pos);
 		if (!Lambda.has(Type.getClassFields(c), n)) {
 		if (!Lambda.has(Type.getClassFields(c), n)) {
 			Test.report(Type.getClassName(c) + " should have static field " +n, pos);
 			Test.report(Type.getClassName(c) + " should have static field " +n, pos);
 			success = false;
 			success = false;
@@ -92,7 +99,7 @@ class Test #if swf_mark implements mt.Protect #end {
 	}
 	}
 
 
 	function nhsf(c:Class<Dynamic> , n:String, ?pos:haxe.PosInfos) {
 	function nhsf(c:Class<Dynamic> , n:String, ?pos:haxe.PosInfos) {
-		Test.count++;
+		Test.incrCount(pos);
 		if (Lambda.has(Type.getClassFields(c), n)) {
 		if (Lambda.has(Type.getClassFields(c), n)) {
 			Test.report(Type.getClassName(c) + " should not have static field " +n, pos);
 			Test.report(Type.getClassName(c) + " should not have static field " +n, pos);
 			success = false;
 			success = false;
@@ -110,7 +117,7 @@ class Test #if swf_mark implements mt.Protect #end {
 		}
 		}
 		asyncWaits.push(pos);
 		asyncWaits.push(pos);
 		f(args,function(v2) {
 		f(args,function(v2) {
-			count++;
+			incrCount(pos);
 			if( !asyncWaits.remove(pos) ) {
 			if( !asyncWaits.remove(pos) ) {
 				report("Double async result",pos);
 				report("Double async result",pos);
 				success = false;
 				success = false;
@@ -131,7 +138,7 @@ class Test #if swf_mark implements mt.Protect #end {
 		}
 		}
 		asyncWaits.push(pos);
 		asyncWaits.push(pos);
 		seterror(function(e) {
 		seterror(function(e) {
-			count++;
+			incrCount(pos);
 			if( asyncWaits.remove(pos) )
 			if( asyncWaits.remove(pos) )
 				checkDone();
 				checkDone();
 			else {
 			else {
@@ -140,7 +147,7 @@ class Test #if swf_mark implements mt.Protect #end {
 			}
 			}
 		});
 		});
 		f(args,function(v) {
 		f(args,function(v) {
-			count++;
+			incrCount(pos);
 			if( asyncWaits.remove(pos) ) {
 			if( asyncWaits.remove(pos) ) {
 				report("No exception occured",pos);
 				report("No exception occured",pos);
 				success = false;
 				success = false;
@@ -353,6 +360,8 @@ class Test #if swf_mark implements mt.Protect #end {
 
 
 		trace("SUCCESS: " + success);
 		trace("SUCCESS: " + success);
 
 
+		out.close();
+
 		#if js
 		#if js
 		if (js.Browser.supported) {
 		if (js.Browser.supported) {
 			untyped js.Browser.window.success = success;
 			untyped js.Browser.window.success = success;