Răsfoiți Sursa

[tests] don't allow `int % 0` to fail

#7034
Simon Krajewski 7 ani în urmă
părinte
comite
419e8f6507
2 a modificat fișierele cu 2 adăugiri și 4 ștergeri
  1. 1 1
      src/macro/eval/evalMisc.ml
  2. 1 3
      tests/unit/src/unitstd/Math.unit.hx

+ 1 - 1
src/macro/eval/evalMisc.ml

@@ -229,7 +229,7 @@ let op_ushr p v1 v2 = match v1,v2 with
 	| _ -> invalid_binop OpUShr v1 v2 p
 
 let op_mod p v1 v2 = match v1,v2 with
-	| VInt32 i1,VInt32 i2 -> vint32 (Int32.rem i1 i2)
+	| VInt32 i1,VInt32 i2 -> (try vint32 (Int32.rem i1 i2) with Division_by_zero -> vfloat nan)
 	| VFloat f1,VFloat f2 -> vfloat (mod_float f1 f2)
 	| VInt32 i1,VFloat f2 -> vfloat (mod_float (Int32.to_float i1) f2)
 	| VFloat f1,VInt32 i2 -> vfloat (mod_float f1 (Int32.to_float i2))

+ 1 - 3
tests/unit/src/unitstd/Math.unit.hx

@@ -58,9 +58,7 @@ Math.isNaN(Math.NEGATIVE_INFINITY / Math.NaN) == true;
 
 // %
 var izero = 0;
-try {
-   Math.isNaN(1%izero) == true;
-} catch (e:Dynamic) { }
+Math.isNaN(1%izero) == true;
 // abs
 Math.abs(-1.223) == 1.223;
 Math.abs(1.223) == 1.223;