Commit 51342423 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Enable more ASM->WASM tests.

R=jarin@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1830703003

Cr-Commit-Position: refs/heads/master@{#35067}
parent 838cea4e
...@@ -165,6 +165,9 @@ function f32_gteq(a, b) { ...@@ -165,6 +165,9 @@ function f32_gteq(a, b) {
var inputs = [ var inputs = [
0, 1, 2, 3, 4, 0, 1, 2, 3, 4,
NaN,
Infinity,
-Infinity,
10, 20, 30, 31, 32, 33, 100, 2000, 10, 20, 30, 31, 32, 33, 100, 2000,
30000, 400000, 5000000, 30000, 400000, 5000000,
100000000, 2000000000, 100000000, 2000000000,
...@@ -173,10 +176,9 @@ var inputs = [ ...@@ -173,10 +176,9 @@ var inputs = [
2147483648, 2147483648,
2147483649, 2147483649,
0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344, 0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344,
0x0000009e, 0x00000043, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c,
0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00, 0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00,
0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff, 0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff,
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff,
-0, -0,
-1, -2, -3, -4, -1, -2, -3, -4,
-10, -20, -30, -31, -32, -33, -100, -2000, -10, -20, -30, -31, -32, -33, -100, -2000,
...@@ -200,8 +202,8 @@ var funcs = [ ...@@ -200,8 +202,8 @@ var funcs = [
f32_sub, f32_sub,
f32_mul, f32_mul,
f32_div, f32_div,
// TODO(bradnelson) f32_ceil, f32_ceil,
// TODO(bradnelson) f32_floor, f32_floor,
// TODO(bradnelson) f32_sqrt, // TODO(bradnelson) f32_sqrt,
// TODO(bradnelson) f32_abs, // TODO(bradnelson) f32_abs,
// TODO(bradnelson) f32_min is wrong for -0 // TODO(bradnelson) f32_min is wrong for -0
...@@ -217,12 +219,21 @@ var funcs = [ ...@@ -217,12 +219,21 @@ var funcs = [
(function () { (function () {
for (func of funcs) { for (func of funcs) {
RunThreeWayTest(WrapInAsmModule(func), function (module) { RunThreeWayTest(WrapInAsmModule(func), function (module) {
if (func.length == 1) {
for (a of inputs) {
assertEquals(func(a), module.main(a));
assertEquals(func(a / 11), module.main(a / 11));
assertEquals(func(a / 430.9), module.main(a / 430.9));
assertEquals(func(a / -31.1), module.main(a / -31.1));
}
} else {
for (a of inputs) { for (a of inputs) {
for (b of inputs) { for (b of inputs) {
assertEquals(func(a, b), module.main(a, b)); assertEquals(func(a, b), module.main(a, b));
assertEquals(func(a / 10, b), module.main(a / 10, b)); assertEquals(func(a / 11, b), module.main(a / 11, b));
assertEquals(func(a, b / 440.9), module.main(a, b / 440.9)); assertEquals(func(a, b / 420.9), module.main(a, b / 420.9));
assertEquals(func(a / -33.1, b), module.main(a / -33.1, b)); assertEquals(func(a / -31.1, b), module.main(a / -31.1, b));
}
} }
} }
}); });
......
...@@ -228,6 +228,9 @@ function f64_atan2(a) { ...@@ -228,6 +228,9 @@ function f64_atan2(a) {
var inputs = [ var inputs = [
0, 1, 2, 3, 4, 0, 1, 2, 3, 4,
NaN,
Infinity,
-Infinity,
10, 20, 30, 31, 32, 33, 100, 2000, 10, 20, 30, 31, 32, 33, 100, 2000,
30000, 400000, 5000000, 30000, 400000, 5000000,
100000000, 2000000000, 100000000, 2000000000,
...@@ -236,10 +239,9 @@ var inputs = [ ...@@ -236,10 +239,9 @@ var inputs = [
2147483648, 2147483648,
2147483649, 2147483649,
0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344, 0x273a798e, 0x187937a3, 0xece3af83, 0x5495a16b, 0x0b668ecc, 0x11223344,
0x0000009e, 0x00000043, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c, 0x0000af73, 0x0000116b, 0x00658ecc, 0x002b3b4c,
0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00, 0x88776655, 0x70000000, 0x07200000, 0x7fffffff, 0x56123761, 0x7fffff00,
0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff, 0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff,
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff,
-0, -0,
-1, -2, -3, -4, -1, -2, -3, -4,
-10, -20, -30, -31, -32, -33, -100, -2000, -10, -20, -30, -31, -32, -33, -100, -2000,
...@@ -269,10 +271,10 @@ var funcs = [ ...@@ -269,10 +271,10 @@ var funcs = [
f64_lteq, f64_lteq,
f64_gt, f64_gt,
f64_gteq, f64_gteq,
// TODO(bradnelson) f64_ceil, f64_ceil,
// TODO(bradnelson) f64_floor, f64_floor,
// TODO(bradnelson) f64_sqrt, // TODO(bradnelson) f64_sqrt,
// TODO(bradnelson) f64_abs, f64_abs,
// TODO(bradnelson) f64_min is wrong for -0 // TODO(bradnelson) f64_min is wrong for -0
// TODO(bradnelson) f64_max is wrong for -0 // TODO(bradnelson) f64_max is wrong for -0
// TODO(bradnelson) f64_acos, // TODO(bradnelson) f64_acos,
......
...@@ -8,6 +8,9 @@ function WrapInAsmModule(func) { ...@@ -8,6 +8,9 @@ function WrapInAsmModule(func) {
function MODULE_NAME(stdlib) { function MODULE_NAME(stdlib) {
"use asm"; "use asm";
var imul = stdlib.Math.imul; var imul = stdlib.Math.imul;
var Math_max = stdlib.Math.max;
var Math_min = stdlib.Math.min;
var Math_abs = stdlib.Math.abs;
FUNC_BODY FUNC_BODY
return {main: FUNC_NAME}; return {main: FUNC_NAME};
...@@ -39,6 +42,9 @@ function RunThreeWayTest(asmfunc, expect) { ...@@ -39,6 +42,9 @@ function RunThreeWayTest(asmfunc, expect) {
} }
const imul = Math.imul; const imul = Math.imul;
const Math_max = Math.max;
const Math_min = Math.min;
const Math_abs = Math.abs;
function i32_add(a, b) { function i32_add(a, b) {
a = a | 0; a = a | 0;
...@@ -160,6 +166,23 @@ function i32_gteq(a, b) { ...@@ -160,6 +166,23 @@ function i32_gteq(a, b) {
return 0; return 0;
} }
function i32_min(a, b) {
a = a | 0;
b = b | 0;
return Math_min(a | 0, b | 0) | 0;
}
function i32_max(a, b) {
a = a | 0;
b = b | 0;
return Math_max(a | 0, b | 0) | 0;
}
function i32_abs(a) {
a = a | 0;
return Math_abs(a | 0) | 0;
}
var inputs = [ var inputs = [
0, 1, 2, 3, 4, 0, 1, 2, 3, 4,
10, 20, 30, 31, 32, 33, 100, 2000, 10, 20, 30, 31, 32, 33, 100, 2000,
...@@ -205,18 +228,23 @@ var funcs = [ ...@@ -205,18 +228,23 @@ var funcs = [
i32_lteq, i32_lteq,
i32_gt, i32_gt,
i32_gteq, i32_gteq,
// TODO(titzer): i32_min i32_min,
// TODO(titzer): i32_max i32_max,
// TODO(titzer): i32_abs i32_abs
]; ];
(function () { (function () {
for (func of funcs) { for (func of funcs) {
RunThreeWayTest(WrapInAsmModule(func), function (module) { RunThreeWayTest(WrapInAsmModule(func), function (module) {
if (func.length == 1) {
for (a of inputs) {
assertEquals(func(a), module.main(a));
}
} else {
for (a of inputs) { for (a of inputs) {
for (b of inputs) { for (b of inputs) {
var expected = func(a, b); assertEquals(func(a, b), module.main(a, b));
assertEquals(expected, module.main(a, b)); }
} }
} }
}); });
......
...@@ -131,7 +131,6 @@ function LargeUnsignedLiterals() { ...@@ -131,7 +131,6 @@ function LargeUnsignedLiterals() {
} }
RunThreeWayTest(LargeUnsignedLiterals, function(module) { RunThreeWayTest(LargeUnsignedLiterals, function(module) {
return; // TODO(bradnelson): unsigned literals are broken!
assertEquals(2147483648, module.a()); assertEquals(2147483648, module.a());
assertEquals(2147483649, module.b()); assertEquals(2147483649, module.b());
assertEquals(0x80000000, module.c()); assertEquals(0x80000000, module.c());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment