Index: test/mjsunit/wasm/import-memory.js |
diff --git a/test/mjsunit/wasm/import-memory.js b/test/mjsunit/wasm/import-memory.js |
index 85f6fbf8c0ad72f60d81b82c26a94c6ef3cbbd59..845da91d1d17bca6545d322edaeb05ef6ed9f49e 100644 |
--- a/test/mjsunit/wasm/import-memory.js |
+++ b/test/mjsunit/wasm/import-memory.js |
@@ -199,3 +199,33 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); |
assertEquals(10*kPageSize, memory.buffer.byteLength); |
assertThrows(() => memory.grow(1)); |
})(); |
+ |
+(function TestGrowMemoryExportedMaximum() { |
+ print("TestGrowMemoryExportedMaximum"); |
+ let initial_size = 1, maximum_size = 10; |
+ var exp_instance; |
+ { |
+ let builder = new WasmModuleBuilder(); |
+ builder.addMemory(initial_size, maximum_size, true); |
+ builder.exportMemoryAs("exported_mem"); |
+ exp_instance = builder.instantiate(); |
+ } |
+ var instance; |
+ { |
+ var builder = new WasmModuleBuilder(); |
+ builder.addImportedMemory("imported_mem"); |
+ builder.addFunction("mem_size", kSig_i_v) |
+ .addBody([kExprMemorySize, kMemoryZero]) |
+ .exportFunc(); |
+ builder.addFunction("grow", kSig_i_i) |
+ .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) |
+ .exportFunc(); |
+ instance = builder.instantiate({ |
+ imported_mem: exp_instance.exports.exported_mem}); |
+ } |
+ for (var i = initial_size; i < maximum_size; i++) { |
+ assertEquals(i, instance.exports.grow(1)); |
+ assertEquals((i+1), instance.exports.mem_size()); |
+ } |
+ assertEquals(-1, instance.exports.grow(1)); |
+})(); |