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

Unified Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1794303002: Fixing +fround(x) in asm typer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-asm-validator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/asm-wasm.js
diff --git a/test/mjsunit/wasm/asm-wasm.js b/test/mjsunit/wasm/asm-wasm.js
index efe596d1afef5d64539feb5a64aa20b82d17b6d8..661358d817ee5531aef5ff5da5a1aa59d515f69d 100644
--- a/test/mjsunit/wasm/asm-wasm.js
+++ b/test/mjsunit/wasm/asm-wasm.js
@@ -1374,6 +1374,89 @@ TestForeignVariables();
})();
+(function TestAbsInt() {
+ function Module(stdlib) {
+ "use asm";
+ var abs = stdlib.Math.abs;
+ function func(x) {
+ x = x | 0;
+ return abs(x|0)|0;
+ }
+ return {func:func};
+ }
+ var m = Wasm.instantiateModuleFromAsm(Module.toString());
+ var values = [0, 1, -1, 0x40000000, 0x7FFFFFFF, -0x80000000];
+ for (var i = 0; i < values.length; i++) {
+ var val = values[i];
+ assertEquals(Math.abs(val) | 0, m.func(val));
+ }
+})();
+
+
+(function TestAbsFloat() {
+ function Module(stdlib) {
+ "use asm";
+ var fround = stdlib.Math.fround;
+ var abs = stdlib.Math.abs;
+ function func(x) {
+ x = fround(x);
+ x = abs(x);
+ return fround(x);
+ }
+ return {func:func};
+ }
+ var m = Wasm.instantiateModuleFromAsm(Module.toString());
+ var values = [
+ 0, -0, 1, -1, 0.9, -0.9, 1.414, 0x7F, -0x80, -0x8000, -0x80000000,
+ 0x7FFF, 0x7FFFFFFF, Infinity, -Infinity, NaN
+ ];
+ for (var i = 0; i < values.length; i++) {
+ var val = values[i];
+ assertEquals(Math.fround(Math.abs(val)), m.func(val));
+ }
+})();
+
+
+(function TestAbsDouble() {
+ function Module(stdlib) {
+ "use asm";
+ var fround = stdlib.Math.fround;
+ var abs = stdlib.Math.abs;
+ function func(x) {
+ x = +x;
+ x = abs(x);
+ return +x;
+ }
+ return {func:func};
+ }
+ var m = Wasm.instantiateModuleFromAsm(Module.toString());
+ var values = [
+ 0, -0, 1, -1, 0.9, -0.9, 1.414, 0x7F, -0x80, -0x8000, -0x80000000,
+ 0x7FFF, 0x7FFFFFFF, Infinity, -Infinity, NaN
+ ];
+ for (var i = 0; i < values.length; i++) {
+ var val = values[i];
+ assertEquals(Math.abs(val), m.func(val));
+ }
+})();
+
+
+(function TestFloatAsDouble() {
+ function Module(stdlib) {
+ "use asm";
+ var fround = stdlib.Math.fround;
+ var abs = stdlib.Math.abs;
+ function func() {
+ var x = fround(1.0);
+ return +fround(x);
+ }
+ return {func:func};
+ }
+ var m = Wasm.instantiateModuleFromAsm(Module.toString());
+ assertEquals(1, m.func());
+})();
+
+
(function TestOr() {
function Module() {
"use asm";
« no previous file with comments | « test/cctest/test-asm-validator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698