Bug 1450310: Move WebAssembly.Global test to the right section; r=lth
authorBenjamin Bouvier <benj@benj.me>
Tue, 03 Apr 2018 16:18:44 +0200
changeset 776790 7e3e50fe7d197df6cef86043c79bc80b88e3b223
parent 776789 05669ce25b032bf83ca38e082e6f2c1bf683ed19
child 776791 b57020e5e59b3448b0d232f77d3ea79f01a8ce11
push id104994
push usermaglione.k@gmail.com
push dateTue, 03 Apr 2018 18:21:08 +0000
reviewerslth
bugs1450310
milestone61.0a1
Bug 1450310: Move WebAssembly.Global test to the right section; r=lth
js/src/jit-test/tests/wasm/globals.js
--- a/js/src/jit-test/tests/wasm/globals.js
+++ b/js/src/jit-test/tests/wasm/globals.js
@@ -125,21 +125,16 @@ module = wasmEvalText(`(module
 assertEq(module.getter(), 42);
 // Adapt to ongoing experiment with WebAssembly.Global.
 // assertEq() will not trigger @@toPrimitive, so we must have a cast here.
 if (typeof WebAssembly.Global === "function")
     assertEq(Number(module.value), 42);
 else
     assertEq(module.value, 42);
 
-assertEq(wasmEvalText(`(module
-    (global (import "a" "b") (mut i32))
-    (func (export "get") (result i32) get_global 0)
-)`, { a: { b: 42 } }).exports.get(), 42);
-
 // Can only import numbers (no implicit coercions).
 module = new WebAssembly.Module(wasmTextToBinary(`(module
     (global (import "globs" "i32") i32)
     (global (import "globs" "f32") f32)
     (global (import "globs" "f64") f32)
 )`));
 
 const assertLinkFails = (m, imp, err) => {
@@ -517,16 +512,24 @@ if (typeof WebAssembly.Global === "funct
         // Set on global object, observe everywhere
         i.exports.g.value = 197;
 
         assertEq(i.exports.g.value, 197);
         assertEq(i.exports.getter(), 197);
         assertEq(j.exports.getter(), 197);
     }
 
+    // Providing a primitive value to an imported global should internally
+    // promote it to a Webassembly.Global object.
+
+    assertEq(wasmEvalText(`(module
+        (global (import "a" "b") (mut i32))
+        (func (export "get") (result i32) get_global 0)
+    )`, { a: { b: 42 } }).exports.get(), 42);
+
     // TEST THIS LAST
 
     // "value" is deletable
     assertEq(delete WebAssembly.Global.prototype.value, true);
     assertEq("value" in WebAssembly.Global.prototype, false);
 
     // ADD NO MORE TESTS HERE!
 }