Skip to content

Commit

Permalink
Simplify raises() by requiring type:Class<T>.
Browse files Browse the repository at this point in the history
Now Haxe will be able to correctly interpret each argument, so we don't have to check `isFunction()`, so JS will work again.
  • Loading branch information
player-03 committed Dec 15, 2023
1 parent f554629 commit d6a544a
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/utest/Assert.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<T>(method:() -> Void, ?type:EitherType<Class<T>, 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<T>(method:() -> Void, ?type:Class<T>, ?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();
Expand Down

0 comments on commit d6a544a

Please sign in to comment.