Index: test/mjsunit/wasm/divrem-trap.js |
diff --git a/test/mjsunit/wasm/divrem-trap.js b/test/mjsunit/wasm/divrem-trap.js |
index 6f3ff5db7369733a7aa8bf667c01ec183c579173..cf4001641ca2b298d36b112f374dbd797e1e3f37 100644 |
--- a/test/mjsunit/wasm/divrem-trap.js |
+++ b/test/mjsunit/wasm/divrem-trap.js |
@@ -7,29 +7,6 @@ |
load("test/mjsunit/wasm/wasm-constants.js"); |
load("test/mjsunit/wasm/wasm-module-builder.js"); |
-function assertTraps(code, msg) { |
- var threwException = true; |
- try { |
- if (typeof code === 'function') { |
- code(); |
- } else { |
- eval(code); |
- } |
- threwException = false; |
- } catch (e) { |
- if (typeof type_opt === 'function') { |
- assertInstanceof(e, type_opt); |
- } |
- if (arguments.length >= 3) { |
- assertEquals(e.type, cause_opt); |
- } |
- // Success. |
- return; |
- } |
- throw new MjsUnitAssertionError("Did not throw exception"); |
-} |
- |
- |
function makeBinop(opcode) { |
var builder = new WasmModuleBuilder(); |
@@ -53,13 +30,18 @@ assertEquals(-33, divs(-336, 10)); |
assertEquals( 44, divu( 445, 10)); |
assertEquals(429496685, divu(-446, 10)); |
-assertTraps(kTrapDivByZero, "divs(100, 0);"); |
-assertTraps(kTrapDivByZero, "divs(-1009, 0);"); |
+assertThrows(() => divs(100, 0), WebAssembly.RuntimeError, |
titzer
2016/11/24 15:37:02
I think we can still keep the helper function, but
ahaas
2016/11/28 09:47:53
Done.
|
+ kTrapMsgs[kTrapDivByZero]); |
+assertThrows(() => divs(-1009, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapDivByZero]); |
-assertTraps(kTrapDivByZero, "divu(200, 0);"); |
-assertTraps(kTrapDivByZero, "divu(-2009, 0);"); |
+assertThrows(() => divu(200, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapDivByZero]); |
+assertThrows(() => divu(-2009, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapDivByZero]); |
-assertTraps(kTrapDivUnrepresentable, "divs(0x80000000, -1)"); |
+assertThrows(() => divs(0x80000000, -1), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapDivUnrepresentable]); |
assertEquals(0, divu(0x80000000, -1)); |
@@ -72,11 +54,15 @@ assertEquals(-6, rems(-336, 10)); |
assertEquals( 5, remu( 445, 10)); |
assertEquals( 3, remu(-443, 10)); |
-assertTraps(kTrapRemByZero, "rems(100, 0);"); |
-assertTraps(kTrapRemByZero, "rems(-1009, 0);"); |
+assertThrows(() => rems(100, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapRemByZero]); |
+assertThrows(() => rems(-1009, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapRemByZero]); |
-assertTraps(kTrapRemByZero, "remu(200, 0);"); |
-assertTraps(kTrapRemByZero, "remu(-2009, 0);"); |
+assertThrows(() => remu(200, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapRemByZero]); |
+assertThrows(() => remu(-2009, 0), WebAssembly.RuntimeError, |
+ kTrapMsgs[kTrapRemByZero]); |
assertEquals(-2147483648, remu(0x80000000, -1)); |
assertEquals(0, rems(0x80000000, -1)); |