Index: test/mjsunit/wasm/memory.js |
diff --git a/test/mjsunit/wasm/memory.js b/test/mjsunit/wasm/memory.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..03b0bac5cbdadcce0b9ce7c3b8ec91aac5f047bf |
--- /dev/null |
+++ b/test/mjsunit/wasm/memory.js |
@@ -0,0 +1,41 @@ |
+// 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. |
+ |
+(function TestConstructor() { |
+ assertTrue(WebAssembly.Memory instanceof Function); |
+ assertSame(WebAssembly.Memory, WebAssembly.Memory.prototype.constructor); |
+ assertTrue(WebAssembly.Memory.prototype.grow instanceof Function); |
+ let desc = Object.getOwnPropertyDescriptor(WebAssembly.Memory.prototype, 'buffer'); |
+ assertTrue(desc.get instanceof Function); |
+ assertSame(undefined, desc.set); |
+ |
+ assertThrows(() => new WebAssembly.Memory(), TypeError); |
+ assertThrows(() => new WebAssembly.Memory(1), TypeError); |
+ assertThrows(() => new WebAssembly.Memory(""), TypeError); |
+ |
+ assertThrows(() => new WebAssembly.Memory({initial: -1}), RangeError); |
+ 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.
|
+ |
+ assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: -1}), RangeError); |
+ assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: 1e20}), RangeError); |
+ assertThrows(() => new WebAssembly.Memory({initial: 10, maximum: 9}), RangeError); |
+ |
+ 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.
|
+ assertSame(WebAssembly.Memory.prototype, memory.__proto__); |
+ 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.
|
+ assertTrue(memory instanceof Object); |
+ assertTrue(memory instanceof WebAssembly.Memory); |
+})(); |
+ |
+(function TestBuffer() { |
+ let memory = new WebAssembly.Memory({initial: 1}); |
+ assertTrue(memory.buffer instanceof Object); |
+ assertTrue(memory.buffer instanceof ArrayBuffer); |
+ assertThrows(() => {'use strict'; memory.buffer = memory.buffer}, TypeError) |
+ assertThrows(() => ({__proto__: memory}).buffer, TypeError) |
+})(); |