From d6a544a97f0129a6a9f5771903003bee0f336974 Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Fri, 15 Dec 2023 15:31:49 -0500 Subject: [PATCH] Simplify `raises()` by requiring `type:Class`. Now Haxe will be able to correctly interpret each argument, so we don't have to check `isFunction()`, so JS will work again. --- src/utest/Assert.hx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/utest/Assert.hx b/src/utest/Assert.hx index 10a74a7..4da6d98 100644 --- a/src/utest/Assert.hx +++ b/src/utest/Assert.hx @@ -661,8 +661,7 @@ class Assert { * @param type The type of the expected error. Defaults to any type (catch all). * @param condition The callback which is called upon an exception. The assertion passes * if this callback returns `true`. Otherwise assertion fails. If `type` is specified, that - * will have already been checked before the function is called. In JavaScript, you must - * specify `type`. + * will have already been checked before the function is called. * @param msgNotThrown An optional error message used when the function fails to raise the expected * exception. If not passed a default one will be used * @param msgWrongType An optional error message used when the function raises the exception but it is @@ -671,13 +670,7 @@ class Assert { * @param pos Code position where the Assert call has been executed. Don't fill it * unless you know what you are doing. */ - public static function raises(method:() -> Void, ?type:EitherType, Any>, ?condition:(e:T)->Bool, ?msgNotThrown : String , ?msgWrongType : String, ?msgWrongCondition : String, ?pos : PosInfos) : Bool { - #if !js - if(Reflect.isFunction(type)) { - condition = (type:Any); - type = null; - } - #end + public static function raises(method:() -> Void, ?type:Class, ?condition:(e:T)->Bool, ?msgNotThrown : String , ?msgWrongType : String, ?msgWrongCondition : String, ?pos : PosInfos) : Bool { var typeDescr = type != null ? "exception of type " + Type.getClassName(type) : "exception"; try { method();