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

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

Issue 2342623002: [wasm] Set up Table and Memory constructors
Patch Set: Eps 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
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 (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 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698