Title: [209863] trunk/JSTests
Revision
209863
Author
[email protected]
Date
2016-12-15 08:53:38 -0800 (Thu, 15 Dec 2016)

Log Message

WebAssembly: test_BuilderJSON.js is broken
https://bugs.webkit.org/show_bug.cgi?id=165893

Reviewed by Michael Saboff.

* wasm/Builder.js:
(const._isValidValue):
* wasm/self-test/test_BuilderJSON.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (209862 => 209863)


--- trunk/JSTests/ChangeLog	2016-12-15 15:46:13 UTC (rev 209862)
+++ trunk/JSTests/ChangeLog	2016-12-15 16:53:38 UTC (rev 209863)
@@ -1,5 +1,16 @@
 2016-12-14  Keith Miller  <[email protected]>
 
+        WebAssembly: test_BuilderJSON.js is broken
+        https://bugs.webkit.org/show_bug.cgi?id=165893
+
+        Reviewed by Michael Saboff.
+
+        * wasm/Builder.js:
+        (const._isValidValue):
+        * wasm/self-test/test_BuilderJSON.js:
+
+2016-12-14  Keith Miller  <[email protected]>
+
         Unreviewed, fix test.
 
         * wasm/function-tests/i32-const.js:

Modified: trunk/JSTests/wasm/Builder.js (209862 => 209863)


--- trunk/JSTests/wasm/Builder.js	2016-12-15 15:46:13 UTC (rev 209862)
+++ trunk/JSTests/wasm/Builder.js	2016-12-15 16:53:38 UTC (rev 209863)
@@ -25,6 +25,7 @@
 
 import * as assert from 'assert.js';
 import * as BuildWebAssembly from 'Builder_WebAssemblyBinary.js';
+import * as LLB from 'LowLevelBinary.js';
 import * as WASM from 'WASM.js';
 
 const _toJavaScriptName = name => {
@@ -36,7 +37,7 @@
 const _isValidValue = (value, type) => {
     switch (type) {
     // We allow both signed and unsigned numbers.
-    case "i32": return -(2 ** 31) <= value && value < 2 ** 32;
+    case "i32": return Math.round(value) === value && LLB.varint32Min <= value && value <= LLB.varuint32Max;
     case "i64": throw new Error(`Unimplemented: value check for ${type}`); // FIXME https://bugs.webkit.org/show_bug.cgi?id=163420 64-bit values
     case "f32": return typeof(value) === "number" && isFinite(value);
     case "f64": return typeof(value) === "number" && isFinite(value);
@@ -279,7 +280,7 @@
         const expect = expectedImms[idx];
         switch (expect.name) {
         case "function_index":
-            assert.truthy(_isValidValue(got, "i32"), `Invalid value on ${op}: got "${got}", expected i32`);
+            assert.truthy(_isValidValue(got, "i32") && got >= 0, `Invalid value on ${op}: got "${got}", expected non-negative i32`);
             // FIXME check function indices. https://bugs.webkit.org/show_bug.cgi?id=163421
             break;
         case "local_index": break; // improve checking https://bugs.webkit.org/show_bug.cgi?id=163421

Modified: trunk/JSTests/wasm/self-test/test_BuilderJSON.js (209862 => 209863)


--- trunk/JSTests/wasm/self-test/test_BuilderJSON.js	2016-12-15 15:46:13 UTC (rev 209862)
+++ trunk/JSTests/wasm/self-test/test_BuilderJSON.js	2016-12-15 16:53:38 UTC (rev 209863)
@@ -482,11 +482,11 @@
 
 (function CallInvalid() {
     for (let c of [-1, 0x100000000, "0", {}, Infinity, -Infinity, NaN, -NaN, null])
-        assertOpThrows(f => f.Call(c), `Expected truthy: Invalid value on call: got "${c}", expected i32`);
+        assertOpThrows(f => f.Call(c), `Expected truthy: Invalid value on call: got "${c}", expected non-negative i32`);
 })();
 
 (function I32ConstValid() {
-    for (let c of [0, 1, 2, 42, 1337, 0xFF, 0xFFFF, 0x7FFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF]) {
+    for (let c of [-100, -1, 0, 1, 2, 42, 1337, 0xFF, 0xFFFF, 0x7FFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF]) {
         const b = (new Builder()).Type().End().Code().Function().I32Const(c).Return().End().End();
         const j = JSON.parse(b.json());
         assert.eq(j.section[1].data[0].code[0].name, "i32.const");
@@ -497,7 +497,7 @@
 })();
 
 (function I32ConstInvalid() {
-    for (let c of [-1, 0x100000000, 0.1, -0.1, "0", {}, Infinity, null])
+    for (let c of [0x100000000, 0.1, -0.1, "0", {}, Infinity, null])
         assertOpThrows(f => f.I32Const(c), `Expected truthy: Invalid value on i32.const: got "${c}", expected i32`);
 })();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to