Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Side by Side Diff: test/mjsunit/wasm/table.js

Issue 2350643003: [wasm] Set up Table and Memory constructors (Closed)
Patch Set: Address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/memory.js ('k') | test/mjsunit/wasm/unicode-validation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 = 1e12;
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 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/memory.js ('k') | test/mjsunit/wasm/unicode-validation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698