diff options
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/exception-handling.js.txt | 8 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js | 72 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js.txt | 7 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 10 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 63 |
5 files changed, 101 insertions, 59 deletions
diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt index 21eb9a70d..ab545aac9 100644 --- a/test/binaryen.js/exception-handling.js.txt +++ b/test/binaryen.js/exception-handling.js.txt @@ -28,7 +28,7 @@ ) ) -getExpressionInfo(throw) = {"id":43,"type":1,"event":"e"} -getExpressionInfo(br_on_exn) = {"id":45,"type":9,"name":"l","event":"e"} -getExpressionInfo(rethrow) = {"id":44,"type":1} -getExpressionInfo(try) = {"id":42,"type":0} +getExpressionInfo(throw) = {"id":44,"type":1,"event":"e"} +getExpressionInfo(br_on_exn) = {"id":46,"type":9,"name":"l","event":"e"} +getExpressionInfo(rethrow) = {"id":45,"type":1} +getExpressionInfo(try) = {"id":43,"type":0} 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(); diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt index 239498b1f..a8946875a 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -64,9 +64,12 @@ (f64.const 3) ) -# Host +# MemorySize +(memory.size) + +# MemoryGrow (memory.grow - (i32.const 1) + (i32.const 2) ) # Load diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 5a3da277e..d985b39aa 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -131,7 +131,8 @@ function test_ids() { console.log("SelectId: " + binaryen.SelectId); console.log("DropId: " + binaryen.DropId); console.log("ReturnId: " + binaryen.ReturnId); - console.log("HostId: " + binaryen.HostId); + console.log("MemorySizeId: " + binaryen.MemorySizeId); + console.log("MemoryGrowId: " + binaryen.MemoryGrowId); console.log("NopId: " + binaryen.NopId); console.log("UnreachableId: " + binaryen.UnreachableId); console.log("AtomicCmpxchgId: " + binaryen.AtomicCmpxchgId); @@ -572,7 +573,12 @@ function test_core() { module.externref.pop(), module.funcref.pop(), module.exnref.pop(), - // TODO: Host + + // Memory + module.memory.size(), + module.memory.grow(makeInt32(0)), + + // Other module.nop(), module.unreachable(), ]; diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 2f75640d1..54052a597 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -57,28 +57,29 @@ BinaryId: 16 SelectId: 17 DropId: 18 ReturnId: 19 -HostId: 20 -NopId: 21 -UnreachableId: 22 -AtomicCmpxchgId: 24 -AtomicRMWId: 23 -AtomicWaitId: 25 -AtomicNotifyId: 26 -SIMDExtractId: 28 -SIMDReplaceId: 29 -SIMDShuffleId: 30 -SIMDTernaryId: 31 -SIMDShiftId: 32 -SIMDLoadId: 33 -MemoryInitId: 34 -DataDropId: 35 -MemoryCopyId: 36 -MemoryFillId: 37 -TryId: 42 -ThrowId: 43 -RethrowId: 44 -BrOnExnId: 45 -PopId: 38 +MemorySizeId: 20 +MemoryGrowId: 21 +NopId: 22 +UnreachableId: 23 +AtomicCmpxchgId: 25 +AtomicRMWId: 24 +AtomicWaitId: 26 +AtomicNotifyId: 27 +SIMDExtractId: 29 +SIMDReplaceId: 30 +SIMDShuffleId: 31 +SIMDTernaryId: 32 +SIMDShiftId: 33 +SIMDLoadId: 34 +MemoryInitId: 35 +DataDropId: 36 +MemoryCopyId: 37 +MemoryFillId: 38 +TryId: 43 +ThrowId: 44 +RethrowId: 45 +BrOnExnId: 46 +PopId: 39 getExpressionInfo={"id":15,"type":4,"op":6} (f32.neg (f32.const -33.61199951171875) @@ -1919,6 +1920,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (drop (pop exnref) ) + (drop + (memory.size) + ) + (drop + (memory.grow + (i32.const 0) + ) + ) (nop) (unreachable) ) @@ -3759,6 +3768,14 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (drop (pop exnref) ) + (drop + (memory.size) + ) + (drop + (memory.grow + (i32.const 0) + ) + ) (nop) (unreachable) ) @@ -4336,5 +4353,5 @@ sizeof Literal: 24 ) ) -getExpressionInfo(memory.grow)={"id":20,"type":2,"op":1,"nameOperand":"","operands":[1]} +getExpressionInfo(memory.grow)={"id":21,"type":2,"delta":1} getExpressionInfo(switch)={"id":5,"type":1,"names":["label"],"defaultName":"label","condition":0,"value":0} |