;; Test `block` operator (module ;; Auxiliary definition (memory 1) (func $dummy) (func (export "empty") (block) (block $l) ) (func (export "singular") (result i32) (block (nop)) (block (result i32) (i32.const 7)) ) (func (export "nested") (result i32) (block (result i32) (block (call $dummy) (block) (nop)) (block (result i32) (call $dummy) (i32.const 9)) ) ) (func (export "deep") (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (block (result i32) (call $dummy) (i32.const 150) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) )) ) (func (export "as-if-condition") (block (result i32) (i32.const 1)) (if (then (call $dummy))) ) (func (export "as-if-then") (result i32) (if (result i32) (i32.const 1) (then (block (result i32) (i32.const 1))) (else (i32.const 2))) ) (func (export "as-if-else") (result i32) (if (result i32) (i32.const 1) (then (i32.const 2)) (else (block (result i32) (i32.const 1)))) ) (func (export "as-br_if-first") (result i32) (block (result i32) (br_if 0 (block (result i32) (i32.const 1)) (i32.const 2))) ) (func (export "as-br_if-last") (result i32) (block (result i32) (br_if 0 (i32.const 2) (block (result i32) (i32.const 1)))) ) (func $f (param i32) (result i32) (local.get 0)) (func (export "as-call-value") (result i32) (call $f (block (result i32) (i32.const 1))) ) (func (export "as-return-value") (result i32) (block (result i32) (i32.const 1)) (return) ) (func (export "as-br-value") (result i32) (block (result i32) (br 0 (block (result i32) (i32.const 1)))) ) (func (export "as-local.set-value") (result i32) (local i32) (local.set 0 (block (result i32) (i32.const 1))) (local.get 0) ) (func (export "as-unary-operand") (result i32) (i32.ctz (block (result i32) (call $dummy) (i32.const 13))) ) (func (export "as-binary-operand") (result i32) (i32.mul (block (result i32) (call $dummy) (i32.const 3)) (block (result i32) (call $dummy) (i32.const 4)) ) ) (func (export "as-test-operand") (result i32) (i32.eqz (block (result i32) (call $dummy) (i32.const 13))) ) (func (export "break-value") (result i32) (block (result i32) (br 0 (i32.const 18)) (i32.const 19)) ) (func (export "break-inner") (result i32) (local i32) (local.set 0 (i32.const 0)) (local.set 0 (i32.add (local.get 0) (block (result i32) (block (result i32) (br 1 (i32.const 0x1)))))) (local.set 0 (i32.add (local.get 0) (block (result i32) (block (br 0)) (i32.const 0x2)))) (local.set 0 (i32.add (local.get 0) (block (result i32) (i32.ctz (br 0 (i32.const 0x4))))) ) (local.set 0 (i32.add (local.get 0) (block (result i32) (i32.ctz (block (result i32) (br 1 (i32.const 0x8)))))) ) (local.get 0) ) (func (export "effects") (result i32) (local i32) (block (local.set 0 (i32.const 1)) (local.set 0 (i32.mul (local.get 0) (i32.const 3))) (local.set 0 (i32.sub (local.get 0) (i32.const 5))) (local.set 0 (i32.mul (local.get 0) (i32.const 7))) (br 0) (local.set 0 (i32.mul (local.get 0) (i32.const 100))) ) (i32.eq (local.get 0) (i32.const -14)) ) ) (assert_return (invoke "empty")) (assert_return (invoke "singular") (i32.const 7)) (assert_return (invoke "nested") (i32.const 9)) (assert_return (invoke "deep") (i32.const 150)) (assert_return (invoke "as-if-condition")) (assert_return (invoke "as-if-then") (i32.const 1)) (assert_return (invoke "as-if-else") (i32.const 2)) (assert_return (invoke "as-br_if-first") (i32.const 1)) (assert_return (invoke "as-br_if-last") (i32.const 2)) (assert_return (invoke "as-call-value") (i32.const 1)) (assert_return (invoke "as-return-value") (i32.const 1)) (assert_return (invoke "as-br-value") (i32.const 1)) (assert_return (invoke "as-local.set-value") (i32.const 1)) (assert_return (invoke "as-unary-operand") (i32.const 0)) (assert_return (invoke "as-binary-operand") (i32.const 12)) (assert_return (invoke "as-test-operand") (i32.const 0)) (assert_return (invoke "break-inner") (i32.const 0xf)) (assert_return (invoke "effects") (i32.const 1))