Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: test/mjsunit/asm/int32mod-constant.js

Issue 2663243002: [asm] Fix lots of invalid asm.js tests (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/asm/int32mod.js ('k') | test/mjsunit/asm/int32modb.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 function Int32Mod(divisor) { 9 function Int32Mod(divisor) {
10 var name = "mod_"; 10 var name = "mod_";
11 if (divisor < 0) { 11 if (divisor < 0) {
12 name += "minus_"; 12 name += "minus_";
13 } 13 }
14 name += Math.abs(divisor); 14 name += Math.abs(divisor);
15 var m = eval("function Module(stdlib, foreign, heap) {\n" 15 var m = eval(
16 + " \"use asm\";\n" 16 'function Module(stdlib, foreign, heap) {\n' +
17 + " function " + name + "(dividend) {\n" 17 ' "use asm";\n' +
18 + " return ((dividend | 0) % " + divisor + ") | 0;\n" 18 ' function ' + name + '(dividend) {\n' +
19 + " }\n" 19 ' dividend = dividend | 0;\n' +
20 + " return { f: " + name + "}\n" 20 ' return ((dividend | 0) % ' + divisor + ') | 0;\n' +
21 + "}; Module"); 21 ' }\n' +
22 ' return { f: ' + name + '}\n' +
23 '}; Module');
22 return m(stdlib, foreign, heap).f; 24 return m(stdlib, foreign, heap).f;
23 } 25 }
24 26
25 var divisors = [-2147483648, -32 * 1024, -1000, -16, -7, -2, -1, 0, 27 var divisors = [-2147483648, -32 * 1024, -1000, -16, -7, -2, -1, 0,
26 1, 3, 4, 10, 64, 100, 1024, 2147483647]; 28 1, 3, 4, 10, 64, 100, 1024, 2147483647];
27 for (var i in divisors) { 29 for (var i in divisors) {
28 var divisor = divisors[i]; 30 var divisor = divisors[i];
29 var mod = Int32Mod(divisor); 31 var mod = Int32Mod(divisor);
30 for (var dividend = -2147483648; dividend < 2147483648; dividend += 3999773) { 32 for (var dividend = -2147483648; dividend < 2147483648; dividend += 3999773) {
31 assertEquals((dividend % divisor) | 0, mod(dividend)); 33 assertEquals((dividend % divisor) | 0, mod(dividend));
32 } 34 }
33 } 35 }
OLDNEW
« no previous file with comments | « test/mjsunit/asm/int32mod.js ('k') | test/mjsunit/asm/int32modb.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698