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

Side by Side Diff: test/mjsunit/wasm/memory.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/common/wasm/wasm-module-runner.cc ('k') | test/mjsunit/wasm/table.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.Memory instanceof Function);
13 assertSame(WebAssembly.Memory, WebAssembly.Memory.prototype.constructor);
14 assertTrue(WebAssembly.Memory.prototype.grow instanceof Function);
15 let desc = Object.getOwnPropertyDescriptor(WebAssembly.Memory.prototype, 'buff er');
16 assertTrue(desc.get instanceof Function);
17 assertSame(undefined, desc.set);
18
19 assertThrows(() => new WebAssembly.Memory(), TypeError);
20 assertThrows(() => new WebAssembly.Memory(1), TypeError);
21 assertThrows(() => new WebAssembly.Memory(""), TypeError);
22
23 assertThrows(() => new WebAssembly.Memory({initial: -1}), RangeError);
24 assertThrows(() => new WebAssembly.Memory({initial: outOfUint32RangeValue}), R angeError);
25
26 assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: -1}), RangeEr ror);
27 assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: outOfUint32Ra ngeValue}), RangeError);
28 assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: 9}), RangeErr or);
29
30 let memory = new WebAssembly.Memory({initial: 1});
31 assertSame(WebAssembly.Memory.prototype, memory.__proto__);
32 assertSame(WebAssembly.Memory, memory.constructor);
33 assertTrue(memory instanceof Object);
34 assertTrue(memory instanceof WebAssembly.Memory);
35 })();
36
37 (function TestConstructorWithMaximum() {
38 let memory = new WebAssembly.Memory({initial: 1, maximum: 10});
39 assertSame(WebAssembly.Memory.prototype, memory.__proto__);
40 assertSame(WebAssembly.Memory, memory.constructor);
41 assertTrue(memory instanceof Object);
42 assertTrue(memory instanceof WebAssembly.Memory);
43 })();
44
45 (function TestBuffer() {
46 let memory = new WebAssembly.Memory({initial: 1});
47 assertTrue(memory.buffer instanceof Object);
48 assertTrue(memory.buffer instanceof ArrayBuffer);
49 assertThrows(() => {'use strict'; memory.buffer = memory.buffer}, TypeError)
50 assertThrows(() => ({__proto__: memory}).buffer, TypeError)
51 })();
OLDNEW
« no previous file with comments | « test/common/wasm/wasm-module-runner.cc ('k') | test/mjsunit/wasm/table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698