summaryrefslogtreecommitdiff
path: root/test/binaryen.js/expressions.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/binaryen.js/expressions.js')
-rw-r--r--test/binaryen.js/expressions.js72
1 files changed, 44 insertions, 28 deletions
diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js
index a0f3e6d4b..a9a0ab982 100644
--- a/test/binaryen.js/expressions.js
+++ b/test/binaryen.js/expressions.js
@@ -465,39 +465,55 @@ console.log("# GlobalSet");
module.dispose();
})();
-console.log("# Host");
-(function testHost() {
+console.log("# MemorySize");
+(function testMemorySize() {
const module = new binaryen.Module();
- var op = binaryen.Operations.MemorySize;
- var nameOp = null;
- var operands = [];
- const theHost = binaryen.Host(module.memory.size());
- assert(theHost instanceof binaryen.Host);
- assert(theHost instanceof binaryen.Expression);
- assert(theHost.op === op);
- assert(theHost.nameOperand === nameOp);
- assertDeepEqual(theHost.operands, operands);
- assert(theHost.type === binaryen.i32);
-
- theHost.op = op = binaryen.Operations.MemoryGrow;
- assert(theHost.op === op);
- theHost.nameOperand = nameOp = "a";
- assert(theHost.nameOperand === nameOp);
- theHost.nameOperand = null;
- theHost.operands = operands = [
- module.i32.const(1)
- ];
- assertDeepEqual(theHost.operands, operands);
- theHost.type = binaryen.f64;
- theHost.finalize();
- assert(theHost.type === binaryen.i32);
+ var type = binaryen.i32;
+ const theMemorySize = binaryen.MemorySize(module.memory.size());
+ assert(theMemorySize instanceof binaryen.MemorySize);
+ assert(theMemorySize instanceof binaryen.Expression);
+ assert(theMemorySize.type === type);
+
+ theMemorySize.type = type = binaryen.f64;
+ assert(theMemorySize.type === type);
+ theMemorySize.finalize();
+ assert(theMemorySize.type === binaryen.i32);
+
+ console.log(theMemorySize.toText());
+ assert(
+ theMemorySize.toText()
+ ==
+ "(memory.size)\n"
+ );
- console.log(theHost.toText());
+ module.dispose();
+})();
+
+console.log("# MemoryGrow");
+(function testMemoryGrow() {
+ const module = new binaryen.Module();
+
+ var type = binaryen.i32;
+ var delta = module.i32.const(1);
+ const theMemoryGrow = binaryen.MemoryGrow(module.memory.grow(delta));
+ assert(theMemoryGrow instanceof binaryen.MemoryGrow);
+ assert(theMemoryGrow instanceof binaryen.Expression);
+ assert(theMemoryGrow.delta === delta);
+ assert(theMemoryGrow.type === type);
+
+ theMemoryGrow.delta = delta = module.i32.const(2);
+ assert(theMemoryGrow.delta === delta);
+ theMemoryGrow.type = type = binaryen.f64;
+ assert(theMemoryGrow.type === type);
+ theMemoryGrow.finalize();
+ assert(theMemoryGrow.type === binaryen.i32);
+
+ console.log(theMemoryGrow.toText());
assert(
- theHost.toText()
+ theMemoryGrow.toText()
==
- "(memory.grow\n (i32.const 1)\n)\n"
+ "(memory.grow\n (i32.const 2)\n)\n"
);
module.dispose();