diff --git a/src/massive/munit/Assert.hx b/src/massive/munit/Assert.hx index 87b07fd..6fc0cff 100644 --- a/src/massive/munit/Assert.hx +++ b/src/massive/munit/Assert.hx @@ -151,7 +151,7 @@ class Assert public static function isType(value:Dynamic, type:Dynamic, ?message:String, ?info:PosInfos) { assertionCount++; - if(Std.is(value, type)) return; + if(isOfType(value, type)) return; if(message == null) message = "Value [" + value + "] was not of type: " + Type.getClassName(type); fail(message, info); } @@ -166,7 +166,7 @@ class Assert public static function isNotType(value:Dynamic, type:Dynamic, ?message:String, ?info:PosInfos) { assertionCount++; - if(!Std.is(value, type)) return; + if(!isOfType(value, type)) return; if(message == null) message = "Value [" + value + "] was of type: " + Type.getClassName(type); fail(message, info); } @@ -290,7 +290,7 @@ class Assert } catch (e:Dynamic) { - if(Std.is(e, expectedType)) return e; + if(isOfType(e, expectedType)) return e; Assert.fail('Expected exception of type ${Type.getClassName(expectedType)} but got ${Type.getClassName(Type.getClass(e))}: ${e}'); } return null; @@ -334,8 +334,8 @@ class Assert case TFunction: Reflect.compareMethods(a, b); case TClass(_): if(a == b) return true; - if(Std.is(a, String) && Std.is(b, String)) return false; // previous comparison failed - if(Std.is(a, Array) && Std.is(b, Array)) { + if(isOfType(a, String) && isOfType(b, String)) return false; // previous comparison failed + if(isOfType(a, Array) && isOfType(b, Array)) { var a:Array = cast a; var b:Array = cast b; if(a.length != b.length) return false; @@ -344,7 +344,7 @@ class Assert } return true; } - if(Std.is(a, Bytes) && Std.is(b, Bytes)) { + if(isOfType(a, Bytes) && isOfType(b, Bytes)) { var a = cast(a, Bytes); var b = cast(b, Bytes); if(a.length != b.length) return false; @@ -353,7 +353,7 @@ class Assert } return true; } - if(Std.is(a, IMap) && Std.is(b, IMap)) { + if(isOfType(a, IMap) && isOfType(b, IMap)) { var a:IMap = cast a; var b:IMap = cast b; var akeys = [for(it in a.keys()) it]; @@ -364,7 +364,7 @@ class Assert } return true; } - if(Std.is(a, Date) && Std.is(b, Date)) { + if(isOfType(a, Date) && isOfType(b, Date)) { var a = cast(a, Date).getTime(); var b = cast(b, Date).getTime(); return a == b; @@ -381,7 +381,7 @@ class Assert } return true; case TObject: - if(Std.is(a, Class) && Std.is(b, Class)) { + if(isOfType(a, Class) && isOfType(b, Class)) { var a = Type.getClassName(a); var b = Type.getClassName(b); return a == b; @@ -417,9 +417,9 @@ class Assert } static inline function empty(anObject:StringOrIterable):Bool { - if(Std.is(anObject, String)) { + if(isOfType(anObject, String)) { return (anObject:String).length == 0; - } else if(Std.is(anObject, Array)) { + } else if(isOfType(anObject, Array)) { var a:Array = cast anObject; return a.length == 0; } else { diff --git a/src/massive/munit/TestResult.hx b/src/massive/munit/TestResult.hx index a6f764e..7778b39 100644 --- a/src/massive/munit/TestResult.hx +++ b/src/massive/munit/TestResult.hx @@ -110,8 +110,7 @@ class TestResult } -@:enum -abstract TestResultType(String) to String +enum abstract TestResultType(String) to String { var UNKNOWN = "UNKNOWN"; var PASS = "PASS"; diff --git a/src/massive/munit/TestRunner.hx b/src/massive/munit/TestRunner.hx index 03bdbc0..d66b307 100644 --- a/src/massive/munit/TestRunner.hx +++ b/src/massive/munit/TestRunner.hx @@ -189,7 +189,13 @@ class TestRunner implements IAsyncDelegateObserver #if (neko || cpp || java || hl || eval) var self = this; - var runThread:Thread = Thread.create(function() + var createThread = Thread.create; + #if haxe4 + #if (haxe >= version("4.2.0-rc.1")) + createThread = Thread.createWithEventLoop; + #end + #end + var runThread:Thread = createThread(function() { self.execute(); while (self.running) @@ -235,7 +241,7 @@ class TestRunner implements IAsyncDelegateObserver var time:Float = Timer.stamp() - startTime; for (client in clients) { - if(Std.is(client, IAdvancedTestResultClient)) + if(isOfType(client, IAdvancedTestResultClient)) { var cl:IAdvancedTestResultClient = cast client; cl.setCurrentTestClass(null); @@ -249,7 +255,7 @@ class TestRunner implements IAsyncDelegateObserver { for(c in clients) { - if(Std.is(c, IAdvancedTestResultClient) && activeHelper.hasNext()) + if(isOfType(c, IAdvancedTestResultClient) && activeHelper.hasNext()) { var cl:IAdvancedTestResultClient = cast c; cl.setCurrentTestClass(activeHelper.className); @@ -310,11 +316,11 @@ class TestRunner implements IAsyncDelegateObserver } #if hamcrest - if (Std.is(e, org.hamcrest.AssertionException)) + if (isOfType(e, org.hamcrest.AssertionException)) e = new AssertionException(e.message, e.info); #end - if (Std.is(e, AssertionException)) + if (isOfType(e, AssertionException)) { result.executionTime = Timer.stamp() - testStartTime; result.failure = e; @@ -325,7 +331,7 @@ class TestRunner implements IAsyncDelegateObserver else { result.executionTime = Timer.stamp() - testStartTime; - if (!Std.is(e, MUnitException)) + if (!isOfType(e, MUnitException)) e = new UnhandledException(e, result.location); result.error = e; diff --git a/src/massive/munit/UnhandledException.hx b/src/massive/munit/UnhandledException.hx index df91fba..62c1108 100644 --- a/src/massive/munit/UnhandledException.hx +++ b/src/massive/munit/UnhandledException.hx @@ -62,7 +62,7 @@ class UnhandledException extends MUnitException { var s = ""; #if flash - if (Std.is(source, flash.errors.Error) && flash.system.Capabilities.isDebugger) + if (isOfType(source, flash.errors.Error) && flash.system.Capabilities.isDebugger) { var lines = source.getStackTrace().split("\n"); lines.shift(); // remove repeated error name @@ -71,7 +71,7 @@ class UnhandledException extends MUnitException #end if (s == "") { - var stack:Array = CallStack.exceptionStack(); + var stack:Array = CallStack.exceptionStack(); while (stack.length > 0) { switch (stack.shift()) diff --git a/src/massive/munit/client/HTTPClient.hx b/src/massive/munit/client/HTTPClient.hx index b72d873..ecad2ae 100644 --- a/src/massive/munit/client/HTTPClient.hx +++ b/src/massive/munit/client/HTTPClient.hx @@ -107,7 +107,7 @@ class HTTPClient implements IAdvancedTestResultClient */ public function setCurrentTestClass(className:String) { - if(Std.is(client, IAdvancedTestResultClient)) + if(isOfType(client, IAdvancedTestResultClient)) { cast(client, IAdvancedTestResultClient).setCurrentTestClass(className); } diff --git a/src/massive/munit/client/PrintClientBase.hx b/src/massive/munit/client/PrintClientBase.hx index 5cda00c..18a6afb 100644 --- a/src/massive/munit/client/PrintClientBase.hx +++ b/src/massive/munit/client/PrintClientBase.hx @@ -406,7 +406,7 @@ class ExternalPrintClientJS implements ExternalPrintClient #end var a:Array = []; - if(Std.is(args, Array)) a = a.concat(cast(args, Array)); + if(isOfType(args, Array)) a = a.concat(cast(args, Array)); else a.push(args); var jsCode = convertToJavaScript(method, a); #if js diff --git a/src/massive/munit/import.hx b/src/massive/munit/import.hx new file mode 100644 index 0000000..edf59db --- /dev/null +++ b/src/massive/munit/import.hx @@ -0,0 +1,11 @@ +package massive.munit; + +#if haxe4 + #if (haxe >= version("4.1.0")) + import Std.isOfType as isOfType; + #else + import Std.is as isOfType; + #end +#else +import Std.is as isOfType; +#end \ No newline at end of file