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

Side by Side Diff: test/mjsunit/wasm/memory.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.Memory instanceof Function);
11 assertSame(WebAssembly.Memory, WebAssembly.Memory.prototype.constructor);
12 assertTrue(WebAssembly.Memory.prototype.grow instanceof Function);
13 let desc = Object.getOwnPropertyDescriptor(WebAssembly.Memory.prototype, 'buff er');
14 assertTrue(desc.get instanceof Function);
15 assertSame(undefined, desc.set);
16
17 assertThrows(() => new WebAssembly.Memory(), TypeError);
18 assertThrows(() => new WebAssembly.Memory(1), TypeError);
19 assertThrows(() => new WebAssembly.Memory(""), TypeError);
20
21 assertThrows(() => new WebAssembly.Memory({initial: -1}), RangeError);
22 assertThrows(() => new WebAssembly.Memory({initial: 1e20}), RangeError);
ahaas 2016/09/15 14:41:07 could you store 1e20 in an outOfUint32RangeValue c
ahaas 2016/09/19 14:02:37 Done.
23
24 assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: -1}), RangeEr ror);
25 assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: 1e20}), Range Error);
26 assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: 9}), RangeErr or);
27
28 let memory = new WebAssembly.Memory({initial: 1});
ahaas 2016/09/15 14:41:06 Can you add a test where the maximum is set, e.g.
ahaas 2016/09/19 14:02:37 Done.
29 assertSame(WebAssembly.Memory.prototype, memory.__proto__);
30 assertSame(WebAssembly.Memory, memory.constructor);
ahaas 2016/09/15 14:41:06 Can you check the value of maximum here?
ahaas 2016/09/19 14:02:37 oh, that's not possible.
31 assertTrue(memory instanceof Object);
32 assertTrue(memory instanceof WebAssembly.Memory);
33 })();
34
35 (function TestBuffer() {
36 let memory = new WebAssembly.Memory({initial: 1});
37 assertTrue(memory.buffer instanceof Object);
38 assertTrue(memory.buffer instanceof ArrayBuffer);
39 assertThrows(() => {'use strict'; memory.buffer = memory.buffer}, TypeError)
40 assertThrows(() => ({__proto__: memory}).buffer, TypeError)
41 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698