Chromium Code Reviews| Index: test/mjsunit/wasm/table.js |
| diff --git a/test/mjsunit/wasm/table.js b/test/mjsunit/wasm/table.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c007b53489cb17bb21e40bc096f972bd277d69b0 |
| --- /dev/null |
| +++ b/test/mjsunit/wasm/table.js |
| @@ -0,0 +1,41 @@ |
| +// 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 |
| + |
| +// Basic tests. |
| + |
| +(function TestConstructor() { |
| + assertTrue(WebAssembly.Table instanceof Function); |
| + assertSame(WebAssembly.Table, WebAssembly.Table.prototype.constructor); |
| + assertTrue(WebAssembly.Table.prototype.grow instanceof Function); |
| + assertTrue(WebAssembly.Table.prototype.get instanceof Function); |
| + assertTrue(WebAssembly.Table.prototype.set instanceof Function); |
| + let desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, 'length'); |
| + assertTrue(desc.get instanceof Function); |
| + assertSame(undefined, desc.set); |
| + |
| + assertThrows(() => new WebAssembly.Table(), TypeError); |
| + assertThrows(() => new WebAssembly.Table(1), TypeError); |
| + assertThrows(() => new WebAssembly.Table(""), TypeError); |
| + |
| + assertThrows(() => new WebAssembly.Table({}), TypeError); |
| + assertThrows(() => new WebAssembly.Table({initial: 10}), TypeError); |
| + |
| + assertThrows(() => new WebAssembly.Table({element: 0, initial: 10}), TypeError); |
| + assertThrows(() => new WebAssembly.Table({element: "any", initial: 10}), TypeError); |
| + |
| + assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: -1}), RangeError); |
| + assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 1e20}), RangeError); |
| + |
| + assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: -1}), RangeError); |
| + assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: 1e20}), RangeError); |
| + assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: 9}), RangeError); |
| + |
| + let table = new WebAssembly.Table({element: "anyfunc", initial: 1}); |
| + assertSame(WebAssembly.Table.prototype, table.__proto__); |
| + assertSame(WebAssembly.Table, table.constructor); |
|
ahaas
2016/09/15 14:41:07
Could you add a test for the maximum property?
ahaas
2016/09/19 14:02:37
Done.
|
| + assertTrue(table instanceof Object); |
| + assertTrue(table instanceof WebAssembly.Table); |
| +})(); |