OLD | NEW |
---|---|
(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 })(); | |
OLD | NEW |