OLD | NEW |
1 // Copyright 2014 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 var stdlib = {}; | 5 var stdlib = {}; |
6 var foreign = {}; | 6 var foreign = {}; |
7 var heap = new ArrayBuffer(64 * 1024); | 7 var heap = new ArrayBuffer(64 * 1024); |
8 | 8 |
9 var mod = (function Module(stdlib, foreign, heap) { | 9 var mod = (function Module(stdlib, foreign, heap) { |
10 "use asm"; | 10 "use asm"; |
11 function mod(dividend, divisor) { | 11 function mod(dividend, divisor) { |
12 dividend = dividend|0; | 12 dividend = dividend|0; |
13 divisor = divisor|0; | 13 divisor = divisor|0; |
14 return (dividend % divisor) | 0; | 14 return (dividend % divisor) | 0; |
15 } | 15 } |
16 return { mod: mod }; | 16 return { mod: mod }; |
17 })(stdlib, foreign, heap).mod; | 17 })(stdlib, foreign, heap).mod; |
18 | 18 |
19 var divisors = [-2147483648, -32 * 1024, -1000, -16, -7, -2, -1, 0, | 19 var divisors = [-2147483648, -32 * 1024, -1000, -16, -7, -2, -1, 0, |
20 1, 3, 4, 10, 64, 100, 1024, 2147483647]; | 20 1, 3, 4, 10, 64, 99, 1023, 1024, 2147483647]; |
21 for (var i in divisors) { | 21 for (var i = 0; i < divisors.length; i++) { |
22 var divisor = divisors[i]; | 22 var divisor = divisors[i]; |
23 for (var dividend = -2147483648; dividend < 2147483648; dividend += 3999773) { | 23 for (var dividend = -2147483648; dividend < 2147483648; dividend += 3999773) { |
24 assertEquals((dividend % divisor) | 0, mod(dividend, divisor)); | 24 assertEquals((dividend % divisor) | 0, mod(dividend, divisor)); |
25 } | 25 } |
26 } | 26 } |
OLD | NEW |