Chromium Code Reviews| 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 (function TestConstructor() { | |
| 10 assertTrue(WebAssembly.Table instanceof Function); | |
| 11 assertSame(WebAssembly.Table, WebAssembly.Table.prototype.constructor); | |
| 12 assertTrue(WebAssembly.Table.prototype.grow instanceof Function); | |
| 13 assertTrue(WebAssembly.Table.prototype.get instanceof Function); | |
| 14 assertTrue(WebAssembly.Table.prototype.set instanceof Function); | |
| 15 let desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, 'lengt h'); | |
| 16 assertTrue(desc.get instanceof Function); | |
| 17 assertSame(undefined, desc.set); | |
| 18 | |
| 19 assertThrows(() => new WebAssembly.Table(), TypeError); | |
| 20 assertThrows(() => new WebAssembly.Table(1), TypeError); | |
| 21 assertThrows(() => new WebAssembly.Table(""), TypeError); | |
| 22 | |
| 23 assertThrows(() => new WebAssembly.Table({}), TypeError); | |
| 24 assertThrows(() => new WebAssembly.Table({initial: 10}), TypeError); | |
| 25 | |
| 26 assertThrows(() => new WebAssembly.Table({element: 0, initial: 10}), TypeError ); | |
| 27 assertThrows(() => new WebAssembly.Table({element: "any", initial: 10}), TypeE rror); | |
| 28 | |
| 29 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: -1}), R angeError); | |
| 30 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 1e20}), RangeError); | |
| 31 | |
| 32 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, max imum: -1}), RangeError); | |
| 33 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, max imum: 1e20}), RangeError); | |
| 34 assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, max imum: 9}), RangeError); | |
| 35 | |
| 36 let table = new WebAssembly.Table({element: "anyfunc", initial: 1}); | |
| 37 assertSame(WebAssembly.Table.prototype, table.__proto__); | |
| 38 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.
| |
| 39 assertTrue(table instanceof Object); | |
| 40 assertTrue(table instanceof WebAssembly.Table); | |
| 41 })(); | |
| OLD | NEW |