OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-wasm |
| 6 |
| 7 // Basic tests. |
| 8 |
| 9 var outOfUint32RangeValue = 1e20; |
| 10 |
| 11 (function TestConstructor() { |
| 12 assertTrue(WebAssembly.Table instanceof Function); |
| 13 assertSame(WebAssembly.Table, WebAssembly.Table.prototype.constructor); |
| 14 assertTrue(WebAssembly.Table.prototype.grow instanceof Function); |
| 15 assertTrue(WebAssembly.Table.prototype.get instanceof Function); |
| 16 assertTrue(WebAssembly.Table.prototype.set instanceof Function); |
| 17 let desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, 'lengt
h'); |
| 18 assertTrue(desc.get instanceof Function); |
| 19 assertSame(undefined, desc.set); |
| 20 |
| 21 assertThrows(() => new WebAssembly.Table(), TypeError); |
| 22 assertThrows(() => new WebAssembly.Table(1), TypeError); |
| 23 assertThrows(() => new WebAssembly.Table(""), TypeError); |
| 24 |
| 25 assertThrows(() => new WebAssembly.Table({}), TypeError); |
| 26 assertThrows(() => new WebAssembly.Table({initial: 10}), TypeError); |
| 27 |
| 28 assertThrows(() => new WebAssembly.Table({element: 0, initial: 10}), TypeError
); |
| 29 assertThrows(() => new WebAssembly.Table({element: "any", initial: 10}), TypeE
rror); |
| 30 |
| 31 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: -1}), R
angeError); |
| 32 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: outOfUi
nt32RangeValue}), RangeError); |
| 33 |
| 34 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, max
imum: -1}), RangeError); |
| 35 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, max
imum: outOfUint32RangeValue}), RangeError); |
| 36 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, max
imum: 9}), RangeError); |
| 37 |
| 38 let table = new WebAssembly.Table({element: "anyfunc", initial: 1}); |
| 39 assertSame(WebAssembly.Table.prototype, table.__proto__); |
| 40 assertSame(WebAssembly.Table, table.constructor); |
| 41 assertTrue(table instanceof Object); |
| 42 assertTrue(table instanceof WebAssembly.Table); |
| 43 })(); |
| 44 |
| 45 (function TestConstructorWithMaximum() { |
| 46 let table = new WebAssembly.Table({element: "anyfunc", initial: 1, maximum: 10
}); |
| 47 assertSame(WebAssembly.Table.prototype, table.__proto__); |
| 48 assertSame(WebAssembly.Table, table.constructor); |
| 49 assertTrue(table instanceof Object); |
| 50 assertTrue(table instanceof WebAssembly.Table); |
| 51 })(); |
OLD | NEW |