OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm --expose-gc --allow-natives-syntax | 5 // Flags: --expose-wasm --expose-gc --allow-natives-syntax |
6 | 6 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
9 | 9 |
10 function assertTraps(code, msg) { | 10 function assertTraps(code, msg) { |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Success. | 26 // Success. |
27 return; | 27 return; |
28 } | 28 } |
29 throw new MjsUnitAssertionError("Did not throw exception"); | 29 throw new MjsUnitAssertionError("Did not throw exception"); |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 function makeBinop(opcode) { | 33 function makeBinop(opcode) { |
34 var builder = new WasmModuleBuilder(); | 34 var builder = new WasmModuleBuilder(); |
35 | 35 |
36 builder.addFunction("main", [kAstI32, kAstI32, kAstI32]) | 36 builder.addFunction("main", kSig_i_ii) |
37 .addBody([ | 37 .addBody([ |
38 kExprGetLocal, 0, // -- | 38 kExprGetLocal, 0, // -- |
39 kExprGetLocal, 1, // -- | 39 kExprGetLocal, 1, // -- |
40 opcode, // -- | 40 opcode, // -- |
41 ]) | 41 ]) |
42 .exportFunc(); | 42 .exportFunc(); |
43 | 43 |
44 return builder.instantiate().exports.main; | 44 return builder.instantiate().exports.main; |
45 } | 45 } |
46 | 46 |
(...skipping 26 matching lines...) Expand all Loading... |
73 assertEquals( 3, remu(-443, 10)); | 73 assertEquals( 3, remu(-443, 10)); |
74 | 74 |
75 assertTraps(kTrapRemByZero, "rems(100, 0);"); | 75 assertTraps(kTrapRemByZero, "rems(100, 0);"); |
76 assertTraps(kTrapRemByZero, "rems(-1009, 0);"); | 76 assertTraps(kTrapRemByZero, "rems(-1009, 0);"); |
77 | 77 |
78 assertTraps(kTrapRemByZero, "remu(200, 0);"); | 78 assertTraps(kTrapRemByZero, "remu(200, 0);"); |
79 assertTraps(kTrapRemByZero, "remu(-2009, 0);"); | 79 assertTraps(kTrapRemByZero, "remu(-2009, 0);"); |
80 | 80 |
81 assertEquals(-2147483648, remu(0x80000000, -1)); | 81 assertEquals(-2147483648, remu(0x80000000, -1)); |
82 assertEquals(0, rems(0x80000000, -1)); | 82 assertEquals(0, rems(0x80000000, -1)); |
OLD | NEW |