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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..04957036514026f44dfc0d0676d0a16bb4327314
--- /dev/null
+++ b/test/mjsunit/wasm/table.js
@@ -0,0 +1,51 @@
+// 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.
+
+var outOfUint32RangeValue = 1e12;
+
+(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: outOfUint32RangeValue}), RangeError);
+
+ assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: -1}), RangeError);
+ assertThrows(() => new WebAssembly.Table({element: "anyfunc", initial: 10, maximum: outOfUint32RangeValue}), 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);
+ assertTrue(table instanceof Object);
+ assertTrue(table instanceof WebAssembly.Table);
+})();
+
+(function TestConstructorWithMaximum() {
+ let table = new WebAssembly.Table({element: "anyfunc", initial: 1, maximum: 10});
+ assertSame(WebAssembly.Table.prototype, table.__proto__);
+ assertSame(WebAssembly.Table, table.constructor);
+ assertTrue(table instanceof Object);
+ assertTrue(table instanceof WebAssembly.Table);
+})();
« 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