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

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

Issue 2474333003: [wasm] Exported memory should set maximum property when maximum is defined. (Closed)
Patch Set: Format Created 4 years, 1 month 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-module.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..83ebaef40aeef23b3f8fc5865adb143499c0bca3 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");
+ var exp_instance;
+ {
+ let builder = new WasmModuleBuilder();
+ builder.addMemory(1, 10, true);
ahaas 2016/11/04 09:12:17 nit: define constants for these values?
gdeepti 2016/11/08 08:01:00 Not adding constants for these values as these are
+ 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});
+ }
+ var current_mem_size = 1;
ahaas 2016/11/04 09:12:17 nit: use the constants you defined above here?
gdeepti 2016/11/08 08:01:00 Removed left over constant.
+ for (var i = 1; i < 10; i++) {
+ assertEquals(i, instance.exports.grow(1));
+ assertEquals((i+1), instance.exports.mem_size());
+ }
+ assertEquals(-1, instance.exports.grow(1));
+})();
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698