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

Unified Diff: test/mjsunit/wasm/grow-memory.js

Issue 2216443002: [wasm] Grow memory should return -1 on failure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments Created 4 years, 4 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 | « src/wasm/wasm-opcodes.h ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/grow-memory.js
diff --git a/test/mjsunit/wasm/grow-memory.js b/test/mjsunit/wasm/grow-memory.js
index cb90a464825e6c07becb771624422e95d8267192..27aca22d1a68060dc3ea95371046cbe5be9cbf4f 100644
--- a/test/mjsunit/wasm/grow-memory.js
+++ b/test/mjsunit/wasm/grow-memory.js
@@ -34,45 +34,33 @@ function testGrowMemoryReadWrite() {
for(offset = 0; offset <= (kPageSize - 4); offset++) {
poke(20);
- assertEquals(peek(), 20);
+ assertEquals(20, peek());
}
for (offset = kPageSize - 3; offset < kPageSize + 4; offset++) {
assertTraps(kTrapMemOutOfBounds, poke);
assertTraps(kTrapMemOutOfBounds, peek);
}
- try {
- assertEquals(growMem(3), 1);
- } catch (e) {
- assertEquals("object", typeof e);
- assertEquals(e.message, kTrapMsgs[kTrapMemAllocationFail]);
- return;
- }
+ assertEquals(1, growMem(3));
for (offset = kPageSize; offset <= 4*kPageSize -4; offset++) {
poke(20);
- assertEquals(peek(), 20);
+ assertEquals(20, peek());
}
for (offset = 4*kPageSize - 3; offset < 4*kPageSize + 4; offset++) {
assertTraps(kTrapMemOutOfBounds, poke);
assertTraps(kTrapMemOutOfBounds, peek);
}
- try {
- assertEquals(growMem(15), 4);
- } catch (e) {
- assertEquals("object", typeof e);
- assertEquals(e.message, kTrapMsgs[kTrapMemAllocationFail]);
- return;
- }
+ assertEquals(4, growMem(15));
for (offset = 4*kPageSize - 3; offset <= 4*kPageSize + 4; offset++) {
poke(20);
- assertEquals(peek(), 20);
+ assertEquals(20, peek());
}
for (offset = 19*kPageSize - 10; offset <= 19*kPageSize - 4; offset++) {
poke(20);
- assertEquals(peek(), 20);
+ assertEquals(20, peek());
}
for (offset = 19*kPageSize - 3; offset < 19*kPageSize + 5; offset++) {
assertTraps(kTrapMemOutOfBounds, poke);
@@ -93,17 +81,11 @@ function testGrowMemoryZeroInitialSize() {
assertTraps(kTrapMemOutOfBounds, peek);
assertTraps(kTrapMemOutOfBounds, poke);
- try {
- assertEquals(growMem(1), 0);
- } catch (e) {
- assertEquals("object", typeof e);
- assertEquals(e.message, kTrapMsgs[kTrapMemAllocationFail]);
- return;
- }
+ assertEquals(0, growMem(1));
for(offset = 0; offset <= kPageSize - 4; offset++) {
poke(20);
- assertEquals(peek(), 20);
+ assertEquals(20, peek());
}
//TODO(gdeepti): Fix tests with correct write boundaries
@@ -119,8 +101,8 @@ function testGrowMemoryTrapMaxPagesZeroInitialMemory() {
var builder = genGrowMemoryBuilder();
var module = builder.instantiate();
var maxPages = 16385;
- function growMem() { return module.exports.grow_memory(maxPages); }
- assertTraps(kTrapMemOutOfBounds, growMem);
+ function growMem(pages) { return module.exports.grow_memory(pages); }
+ assertEquals(-1, growMem(maxPages));
}
testGrowMemoryTrapMaxPagesZeroInitialMemory();
@@ -130,8 +112,8 @@ function testGrowMemoryTrapMaxPages() {
builder.addMemory(1, 1, false);
var module = builder.instantiate();
var maxPages = 16384;
- function growMem() { return module.exports.grow_memory(maxPages); }
- assertTraps(kTrapMemOutOfBounds, growMem);
+ function growMem(pages) { return module.exports.grow_memory(pages); }
+ assertEquals(-1, growMem(maxPages));
}
testGrowMemoryTrapMaxPages();
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698