diff options
Diffstat (limited to 'deps/v8/test/mjsunit/wasm/export-table.js')
-rw-r--r-- | deps/v8/test/mjsunit/wasm/export-table.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/wasm/export-table.js b/deps/v8/test/mjsunit/wasm/export-table.js new file mode 100644 index 0000000000..e85da9b664 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/export-table.js @@ -0,0 +1,50 @@ +// Copyright 2016 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"); + +(function testExportedMain() { + var kReturnValue = 88; + var builder = new WasmModuleBuilder(); + + builder.addFunction("main", [kAstI32]) + .addBody([ + kExprReturn, + kExprI8Const, + kReturnValue]) + .exportFunc(); + + var module = builder.instantiate(); + + assertEquals("object", typeof module.exports); + assertEquals("function", typeof module.exports.main); + + assertEquals(kReturnValue, module.exports.main()); +})(); + +(function testExportedTwice() { + var kReturnValue = 99; + + var builder = new WasmModuleBuilder(); + + builder.addFunction("main", [kAstI32]) + .addBody([ + kExprReturn, + kExprI8Const, + kReturnValue]) + .exportAs("blah") + .exportAs("foo"); + + var module = builder.instantiate(); + + assertEquals("object", typeof module.exports); + assertEquals("function", typeof module.exports.blah); + assertEquals("function", typeof module.exports.foo); + + assertEquals(kReturnValue, module.exports.foo()); + assertEquals(kReturnValue, module.exports.blah()); +})(); |