Changeset 209863 in webkit


Ignore:
Timestamp:
Dec 15, 2016 8:53:38 AM (7 years ago)
Author:
keith_miller@apple.com
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:
Location:
trunk/JSTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r209853 r209863  
     12016-12-14  Keith Miller  <keith_miller@apple.com>
     2
     3        WebAssembly: test_BuilderJSON.js is broken
     4        https://bugs.webkit.org/show_bug.cgi?id=165893
     5
     6        Reviewed by Michael Saboff.
     7
     8        * wasm/Builder.js:
     9        (const._isValidValue):
     10        * wasm/self-test/test_BuilderJSON.js:
     11
    1122016-12-14  Keith Miller  <keith_miller@apple.com>
    213
  • trunk/JSTests/wasm/Builder.js

    r209852 r209863  
    2626import * as assert from 'assert.js';
    2727import * as BuildWebAssembly from 'Builder_WebAssemblyBinary.js';
     28import * as LLB from 'LowLevelBinary.js';
    2829import * as WASM from 'WASM.js';
    2930
     
    3738    switch (type) {
    3839    // We allow both signed and unsigned numbers.
    39     case "i32": return -(2 ** 31) <= value && value < 2 ** 32;
     40    case "i32": return Math.round(value) === value && LLB.varint32Min <= value && value <= LLB.varuint32Max;
    4041    case "i64": throw new Error(`Unimplemented: value check for ${type}`); // FIXME https://bugs.webkit.org/show_bug.cgi?id=163420 64-bit values
    4142    case "f32": return typeof(value) === "number" && isFinite(value);
     
    280281        switch (expect.name) {
    281282        case "function_index":
    282             assert.truthy(_isValidValue(got, "i32"), `Invalid value on ${op}: got "${got}", expected i32`);
     283            assert.truthy(_isValidValue(got, "i32") && got >= 0, `Invalid value on ${op}: got "${got}", expected non-negative i32`);
    283284            // FIXME check function indices. https://bugs.webkit.org/show_bug.cgi?id=163421
    284285            break;
  • trunk/JSTests/wasm/self-test/test_BuilderJSON.js

    r209651 r209863  
    483483(function CallInvalid() {
    484484    for (let c of [-1, 0x100000000, "0", {}, Infinity, -Infinity, NaN, -NaN, null])
    485         assertOpThrows(f => f.Call(c), `Expected truthy: Invalid value on call: got "${c}", expected i32`);
     485        assertOpThrows(f => f.Call(c), `Expected truthy: Invalid value on call: got "${c}", expected non-negative i32`);
    486486})();
    487487
    488488(function I32ConstValid() {
    489     for (let c of [0, 1, 2, 42, 1337, 0xFF, 0xFFFF, 0x7FFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF]) {
     489    for (let c of [-100, -1, 0, 1, 2, 42, 1337, 0xFF, 0xFFFF, 0x7FFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF]) {
    490490        const b = (new Builder()).Type().End().Code().Function().I32Const(c).Return().End().End();
    491491        const j = JSON.parse(b.json());
     
    498498
    499499(function I32ConstInvalid() {
    500     for (let c of [-1, 0x100000000, 0.1, -0.1, "0", {}, Infinity, null])
     500    for (let c of [0x100000000, 0.1, -0.1, "0", {}, Infinity, null])
    501501        assertOpThrows(f => f.I32Const(c), `Expected truthy: Invalid value on i32.const: got "${c}", expected i32`);
    502502})();
Note: See TracChangeset for help on using the changeset viewer.