Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Thread.create issue with Haxe nightlies #188

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/massive/munit/Assert.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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(isTypeof(value, type)) return;
if(message == null) message = "Value [" + value + "] was not of type: " + Type.getClassName(type);
fail(message, info);
}
Expand All @@ -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(!isTypeof(value, type)) return;
if(message == null) message = "Value [" + value + "] was of type: " + Type.getClassName(type);
fail(message, info);
}
Expand Down Expand Up @@ -290,7 +290,7 @@ class Assert
}
catch (e:Dynamic)
{
if(Std.is(e, expectedType)) return e;
if(isTypeof(e, expectedType)) return e;
Assert.fail('Expected exception of type ${Type.getClassName(expectedType)} but got ${Type.getClassName(Type.getClass(e))}: ${e}');
}
return null;
Expand Down Expand Up @@ -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(isTypeof(a, String) && isTypeof(b, String)) return false; // previous comparison failed
if(isTypeof(a, Array) && isTypeof(b, Array)) {
var a:Array<Dynamic> = cast a;
var b:Array<Dynamic> = cast b;
if(a.length != b.length) return false;
Expand All @@ -344,7 +344,7 @@ class Assert
}
return true;
}
if(Std.is(a, Bytes) && Std.is(b, Bytes)) {
if(isTypeof(a, Bytes) && isTypeof(b, Bytes)) {
var a = cast(a, Bytes);
var b = cast(b, Bytes);
if(a.length != b.length) return false;
Expand All @@ -353,7 +353,7 @@ class Assert
}
return true;
}
if(Std.is(a, IMap) && Std.is(b, IMap)) {
if(isTypeof(a, IMap) && isTypeof(b, IMap)) {
var a:IMap<Dynamic, Dynamic> = cast a;
var b:IMap<Dynamic, Dynamic> = cast b;
var akeys = [for(it in a.keys()) it];
Expand All @@ -364,7 +364,7 @@ class Assert
}
return true;
}
if(Std.is(a, Date) && Std.is(b, Date)) {
if(isTypeof(a, Date) && isTypeof(b, Date)) {
var a = cast(a, Date).getTime();
var b = cast(b, Date).getTime();
return a == b;
Expand All @@ -381,7 +381,7 @@ class Assert
}
return true;
case TObject:
if(Std.is(a, Class) && Std.is(b, Class)) {
if(isTypeof(a, Class) && isTypeof(b, Class)) {
var a = Type.getClassName(a);
var b = Type.getClassName(b);
return a == b;
Expand Down Expand Up @@ -417,9 +417,9 @@ class Assert
}

static inline function empty(anObject:StringOrIterable):Bool {
if(Std.is(anObject, String)) {
if(isTypeof(anObject, String)) {
return (anObject:String).length == 0;
} else if(Std.is(anObject, Array)) {
} else if(isTypeof(anObject, Array)) {
var a:Array<Dynamic> = cast anObject;
return a.length == 0;
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/massive/munit/TestRunner.hx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class TestRunner implements IAsyncDelegateObserver
var time:Float = Timer.stamp() - startTime;
for (client in clients)
{
if(Std.is(client, IAdvancedTestResultClient))
if(isTypeof(client, IAdvancedTestResultClient))
{
var cl:IAdvancedTestResultClient = cast client;
cl.setCurrentTestClass(null);
Expand All @@ -255,7 +255,7 @@ class TestRunner implements IAsyncDelegateObserver
{
for(c in clients)
{
if(Std.is(c, IAdvancedTestResultClient) && activeHelper.hasNext())
if(isTypeof(c, IAdvancedTestResultClient) && activeHelper.hasNext())
{
var cl:IAdvancedTestResultClient = cast c;
cl.setCurrentTestClass(activeHelper.className);
Expand Down Expand Up @@ -316,11 +316,11 @@ class TestRunner implements IAsyncDelegateObserver
}

#if hamcrest
if (Std.is(e, org.hamcrest.AssertionException))
if (isTypeof(e, org.hamcrest.AssertionException))
e = new AssertionException(e.message, e.info);
#end

if (Std.is(e, AssertionException))
if (isTypeof(e, AssertionException))
{
result.executionTime = Timer.stamp() - testStartTime;
result.failure = e;
Expand All @@ -331,7 +331,7 @@ class TestRunner implements IAsyncDelegateObserver
else
{
result.executionTime = Timer.stamp() - testStartTime;
if (!Std.is(e, MUnitException))
if (!isTypeof(e, MUnitException))
e = new UnhandledException(e, result.location);

result.error = e;
Expand Down
2 changes: 1 addition & 1 deletion src/massive/munit/UnhandledException.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class UnhandledException extends MUnitException
{
var s = "";
#if flash
if (Std.is(source, flash.errors.Error) && flash.system.Capabilities.isDebugger)
if (isTypeof(source, flash.errors.Error) && flash.system.Capabilities.isDebugger)
{
var lines = source.getStackTrace().split("\n");
lines.shift(); // remove repeated error name
Expand Down
2 changes: 1 addition & 1 deletion src/massive/munit/client/HTTPClient.hx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class HTTPClient implements IAdvancedTestResultClient
*/
public function setCurrentTestClass(className:String)
{
if(Std.is(client, IAdvancedTestResultClient))
if(isTypeof(client, IAdvancedTestResultClient))
{
cast(client, IAdvancedTestResultClient).setCurrentTestClass(className);
}
Expand Down
2 changes: 1 addition & 1 deletion src/massive/munit/client/PrintClientBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class ExternalPrintClientJS implements ExternalPrintClient
#end

var a:Array<Dynamic> = [];
if(Std.is(args, Array)) a = a.concat(cast(args, Array<Dynamic>));
if(isTypeof(args, Array)) a = a.concat(cast(args, Array<Dynamic>));
else a.push(args);
var jsCode = convertToJavaScript(method, a);
#if js
Expand Down
11 changes: 11 additions & 0 deletions src/massive/munit/import.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package massive.munit;

#if haxe4
#if (haxe >= version("4.1.0"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add tab?

#if haxe4
    #if (...
    #else
        ...
    #end
#else
    ...
#end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and

import Std.isOfType as isOfType;

;)

import Std.isOfType as isTypeof;
#else
import Std.is as isTypeof;
#end
#else
import Std.is as isTypeof;
#end