mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --expose-wasm
|
|
|
|
load("test/mjsunit/wasm/wasm-constants.js");
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
var kReturnValue = 117;
|
|
|
|
var module = (function Build() {
|
|
var builder = new WasmModuleBuilder();
|
|
|
|
builder.addMemory(1, 1, true);
|
|
builder.addFunction("main", [kAstI32])
|
|
.addBody([kExprI8Const, kReturnValue])
|
|
.exportFunc();
|
|
|
|
return builder.instantiate();
|
|
})();
|
|
|
|
// Check the module exists.
|
|
assertFalse(module === undefined);
|
|
assertFalse(module === null);
|
|
assertFalse(module === 0);
|
|
assertEquals("object", typeof module);
|
|
|
|
// Check the memory is an ArrayBuffer.
|
|
var mem = module.exports.memory;
|
|
assertFalse(mem === undefined);
|
|
assertFalse(mem === null);
|
|
assertFalse(mem === 0);
|
|
assertEquals("object", typeof mem);
|
|
assertTrue(mem instanceof ArrayBuffer);
|
|
for (var i = 0; i < 4; i++) {
|
|
module.exports.memory = 0; // should be ignored
|
|
assertEquals(mem, module.exports.memory);
|
|
}
|
|
|
|
assertEquals(65536, module.exports.memory.byteLength);
|
|
|
|
// Check the properties of the main function.
|
|
var main = module.exports.main;
|
|
assertFalse(main === undefined);
|
|
assertFalse(main === null);
|
|
assertFalse(main === 0);
|
|
assertEquals("function", typeof main);
|
|
|
|
assertEquals(kReturnValue, main());
|
|
|