diff --git a/examples/loop.wat b/examples/loop.wat new file mode 100644 index 000000000..1055fdd12 --- /dev/null +++ b/examples/loop.wat @@ -0,0 +1,26 @@ +(module + ;; dummy memory + (memory 1) + + ;; Entry point + (func $main (result i32) + (local $total i32) + (local $count i32) + (set_local $count (i32.const 10)) ;; Giving $count an inital value of 10 + + ;; Iteratively decrement $count and increment $total by 2 + (loop $loop + (if (i32.eqz (get_local $count)) + (then) + (else + (set_local $count (i32.sub (get_local $count) (i32.const 1))) + (set_local $total (i32.add (get_local $total) (i32.const 2))) + (br $loop) + ) + ) + ) + (get_local $total) + ) + + (export "main" (func $main)) +) diff --git a/examples/select.wat b/examples/select.wat new file mode 100644 index 000000000..f969efe2a --- /dev/null +++ b/examples/select.wat @@ -0,0 +1,23 @@ +(module + (func $ternary (param $lhs i64) (param $rhs i64) (param $cond i32) (result i64) + (select + (get_local $lhs) + (get_local $rhs) + (get_local $cond) + ) + ) + + (func $main (result i64) + (call $ternary + (i64.const 126) + (call $ternary + (i64.const 1024) + (i64.const 4028) + (i32.const 0) + ) + (i32.const 0) + ) + ) + + (export "main" (func $main)) +) diff --git a/spectests/endianness.wast b/spectests/endianness.wast new file mode 100644 index 000000000..8dc0c2e2e --- /dev/null +++ b/spectests/endianness.wast @@ -0,0 +1,217 @@ +(module + (memory 1) + + ;; Stores an i16 value in little-endian-format + (func $i16_store_little (param $address i32) (param $value i32) + (i32.store8 (get_local $address) (get_local $value)) + (i32.store8 (i32.add (get_local $address) (i32.const 1)) (i32.shr_u (get_local $value) (i32.const 8))) + ) + + ;; Stores an i32 value in little-endian format + (func $i32_store_little (param $address i32) (param $value i32) + (call $i16_store_little (get_local $address) (get_local $value)) + (call $i16_store_little (i32.add (get_local $address) (i32.const 2)) (i32.shr_u (get_local $value) (i32.const 16))) + ) + + ;; Stores an i64 value in little-endian format + (func $i64_store_little (param $address i32) (param $value i64) + (call $i32_store_little (get_local $address) (i32.wrap/i64 (get_local $value))) + (call $i32_store_little (i32.add (get_local $address) (i32.const 4)) (i32.wrap/i64 (i64.shr_u (get_local $value) (i64.const 32)))) + ) + + ;; Loads an i16 value in little-endian format + (func $i16_load_little (param $address i32) (result i32) + (i32.or + (i32.load8_u (get_local $address)) + (i32.shl (i32.load8_u (i32.add (get_local $address) (i32.const 1))) (i32.const 8)) + ) + ) + + ;; Loads an i32 value in little-endian format + (func $i32_load_little (param $address i32) (result i32) + (i32.or + (call $i16_load_little (get_local $address)) + (i32.shl (call $i16_load_little (i32.add (get_local $address) (i32.const 2))) (i32.const 16)) + ) + ) + + ;; Loads an i64 value in little-endian format + (func $i64_load_little (param $address i32) (result i64) + (i64.or + (i64.extend_u/i32 (call $i32_load_little (get_local $address))) + (i64.shl (i64.extend_u/i32 (call $i32_load_little (i32.add (get_local $address) (i32.const 4)))) (i64.const 32)) + ) + ) + + (func (export "i32_load16_s") (param $value i32) (result i32) + (call $i16_store_little (i32.const 0) (get_local $value)) + (i32.load16_s (i32.const 0)) + ) + + (func (export "i32_load16_u") (param $value i32) (result i32) + (call $i16_store_little (i32.const 0) (get_local $value)) + (i32.load16_u (i32.const 0)) + ) + + (func (export "i32_load") (param $value i32) (result i32) + (call $i32_store_little (i32.const 0) (get_local $value)) + (i32.load (i32.const 0)) + ) + + (func (export "i64_load16_s") (param $value i64) (result i64) + (call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value))) + (i64.load16_s (i32.const 0)) + ) + + (func (export "i64_load16_u") (param $value i64) (result i64) + (call $i16_store_little (i32.const 0) (i32.wrap/i64 (get_local $value))) + (i64.load16_u (i32.const 0)) + ) + + (func (export "i64_load32_s") (param $value i64) (result i64) + (call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value))) + (i64.load32_s (i32.const 0)) + ) + + (func (export "i64_load32_u") (param $value i64) (result i64) + (call $i32_store_little (i32.const 0) (i32.wrap/i64 (get_local $value))) + (i64.load32_u (i32.const 0)) + ) + + (func (export "i64_load") (param $value i64) (result i64) + (call $i64_store_little (i32.const 0) (get_local $value)) + (i64.load (i32.const 0)) + ) + + (func (export "f32_load") (param $value f32) (result f32) + (call $i32_store_little (i32.const 0) (i32.reinterpret/f32 (get_local $value))) + (f32.load (i32.const 0)) + ) + + (func (export "f64_load") (param $value f64) (result f64) + (call $i64_store_little (i32.const 0) (i64.reinterpret/f64 (get_local $value))) + (f64.load (i32.const 0)) + ) + + + (func (export "i32_store16") (param $value i32) (result i32) + (i32.store16 (i32.const 0) (get_local $value)) + (call $i16_load_little (i32.const 0)) + ) + + (func (export "i32_store") (param $value i32) (result i32) + (i32.store (i32.const 0) (get_local $value)) + (call $i32_load_little (i32.const 0)) + ) + + (func (export "i64_store16") (param $value i64) (result i64) + (i64.store16 (i32.const 0) (get_local $value)) + (i64.extend_u/i32 (call $i16_load_little (i32.const 0))) + ) + + (func (export "i64_store32") (param $value i64) (result i64) + (i64.store32 (i32.const 0) (get_local $value)) + (i64.extend_u/i32 (call $i32_load_little (i32.const 0))) + ) + + (func (export "i64_store") (param $value i64) (result i64) + (i64.store (i32.const 0) (get_local $value)) + (call $i64_load_little (i32.const 0)) + ) + + (func (export "f32_store") (param $value f32) (result f32) + (f32.store (i32.const 0) (get_local $value)) + (f32.reinterpret/i32 (call $i32_load_little (i32.const 0))) + ) + + (func (export "f64_store") (param $value f64) (result f64) + (f64.store (i32.const 0) (get_local $value)) + (f64.reinterpret/i64 (call $i64_load_little (i32.const 0))) + ) +) + +(assert_return (invoke "i32_load16_s" (i32.const -1)) (i32.const -1)) +(assert_return (invoke "i32_load16_s" (i32.const -4242)) (i32.const -4242)) +(assert_return (invoke "i32_load16_s" (i32.const 42)) (i32.const 42)) +(assert_return (invoke "i32_load16_s" (i32.const 0x3210)) (i32.const 0x3210)) + +(assert_return (invoke "i32_load16_u" (i32.const -1)) (i32.const 0xFFFF)) +(assert_return (invoke "i32_load16_u" (i32.const -4242)) (i32.const 61294)) +(assert_return (invoke "i32_load16_u" (i32.const 42)) (i32.const 42)) +(assert_return (invoke "i32_load16_u" (i32.const 0xCAFE)) (i32.const 0xCAFE)) + +(assert_return (invoke "i32_load" (i32.const -1)) (i32.const -1)) +(assert_return (invoke "i32_load" (i32.const -42424242)) (i32.const -42424242)) +(assert_return (invoke "i32_load" (i32.const 42424242)) (i32.const 42424242)) +(assert_return (invoke "i32_load" (i32.const 0xABAD1DEA)) (i32.const 0xABAD1DEA)) + +(assert_return (invoke "i64_load16_s" (i64.const -1)) (i64.const -1)) +(assert_return (invoke "i64_load16_s" (i64.const -4242)) (i64.const -4242)) +(assert_return (invoke "i64_load16_s" (i64.const 42)) (i64.const 42)) +(assert_return (invoke "i64_load16_s" (i64.const 0x3210)) (i64.const 0x3210)) + +(assert_return (invoke "i64_load16_u" (i64.const -1)) (i64.const 0xFFFF)) +(assert_return (invoke "i64_load16_u" (i64.const -4242)) (i64.const 61294)) +(assert_return (invoke "i64_load16_u" (i64.const 42)) (i64.const 42)) +(assert_return (invoke "i64_load16_u" (i64.const 0xCAFE)) (i64.const 0xCAFE)) + +(assert_return (invoke "i64_load32_s" (i64.const -1)) (i64.const -1)) +(assert_return (invoke "i64_load32_s" (i64.const -42424242)) (i64.const -42424242)) +(assert_return (invoke "i64_load32_s" (i64.const 42424242)) (i64.const 42424242)) +(assert_return (invoke "i64_load32_s" (i64.const 0x12345678)) (i64.const 0x12345678)) + +(assert_return (invoke "i64_load32_u" (i64.const -1)) (i64.const 0xFFFFFFFF)) +(assert_return (invoke "i64_load32_u" (i64.const -42424242)) (i64.const 4252543054)) +(assert_return (invoke "i64_load32_u" (i64.const 42424242)) (i64.const 42424242)) +(assert_return (invoke "i64_load32_u" (i64.const 0xABAD1DEA)) (i64.const 0xABAD1DEA)) + +(assert_return (invoke "i64_load" (i64.const -1)) (i64.const -1)) +(assert_return (invoke "i64_load" (i64.const -42424242)) (i64.const -42424242)) +(assert_return (invoke "i64_load" (i64.const 0xABAD1DEA)) (i64.const 0xABAD1DEA)) +(assert_return (invoke "i64_load" (i64.const 0xABADCAFEDEAD1DEA)) (i64.const 0xABADCAFEDEAD1DEA)) + +(assert_return (invoke "f32_load" (f32.const -1)) (f32.const -1)) +(assert_return (invoke "f32_load" (f32.const 1234e-5)) (f32.const 1234e-5)) +(assert_return (invoke "f32_load" (f32.const 4242.4242)) (f32.const 4242.4242)) +(assert_return (invoke "f32_load" (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127)) + +(assert_return (invoke "f64_load" (f64.const -1)) (f64.const -1)) +(assert_return (invoke "f64_load" (f64.const 123456789e-5)) (f64.const 123456789e-5)) +(assert_return (invoke "f64_load" (f64.const 424242.424242)) (f64.const 424242.424242)) +(assert_return (invoke "f64_load" (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023)) + + +(assert_return (invoke "i32_store16" (i32.const -1)) (i32.const 0xFFFF)) +(assert_return (invoke "i32_store16" (i32.const -4242)) (i32.const 61294)) +(assert_return (invoke "i32_store16" (i32.const 42)) (i32.const 42)) +(assert_return (invoke "i32_store16" (i32.const 0xCAFE)) (i32.const 0xCAFE)) + +(assert_return (invoke "i32_store" (i32.const -1)) (i32.const -1)) +(assert_return (invoke "i32_store" (i32.const -4242)) (i32.const -4242)) +(assert_return (invoke "i32_store" (i32.const 42424242)) (i32.const 42424242)) +(assert_return (invoke "i32_store" (i32.const 0xDEADCAFE)) (i32.const 0xDEADCAFE)) + +(assert_return (invoke "i64_store16" (i64.const -1)) (i64.const 0xFFFF)) +(assert_return (invoke "i64_store16" (i64.const -4242)) (i64.const 61294)) +(assert_return (invoke "i64_store16" (i64.const 42)) (i64.const 42)) +(assert_return (invoke "i64_store16" (i64.const 0xCAFE)) (i64.const 0xCAFE)) + +(assert_return (invoke "i64_store32" (i64.const -1)) (i64.const 0xFFFFFFFF)) +(assert_return (invoke "i64_store32" (i64.const -4242)) (i64.const 4294963054)) +(assert_return (invoke "i64_store32" (i64.const 42424242)) (i64.const 42424242)) +(assert_return (invoke "i64_store32" (i64.const 0xDEADCAFE)) (i64.const 0xDEADCAFE)) + +(assert_return (invoke "i64_store" (i64.const -1)) (i64.const -1)) +(assert_return (invoke "i64_store" (i64.const -42424242)) (i64.const -42424242)) +(assert_return (invoke "i64_store" (i64.const 0xABAD1DEA)) (i64.const 0xABAD1DEA)) +(assert_return (invoke "i64_store" (i64.const 0xABADCAFEDEAD1DEA)) (i64.const 0xABADCAFEDEAD1DEA)) + +(assert_return (invoke "f32_store" (f32.const -1)) (f32.const -1)) +(assert_return (invoke "f32_store" (f32.const 1234e-5)) (f32.const 1234e-5)) +(assert_return (invoke "f32_store" (f32.const 4242.4242)) (f32.const 4242.4242)) +(assert_return (invoke "f32_store" (f32.const 0x1.fffffep+127)) (f32.const 0x1.fffffep+127)) + +(assert_return (invoke "f64_store" (f64.const -1)) (f64.const -1)) +(assert_return (invoke "f64_store" (f64.const 123456789e-5)) (f64.const 123456789e-5)) +(assert_return (invoke "f64_store" (f64.const 424242.424242)) (f64.const 424242.424242)) +(assert_return (invoke "f64_store" (f64.const 0x1.fffffffffffffp+1023)) (f64.const 0x1.fffffffffffffp+1023)) diff --git a/spectests/float_literals.wast b/spectests/float_literals.wast new file mode 100644 index 000000000..28acabec2 --- /dev/null +++ b/spectests/float_literals.wast @@ -0,0 +1,507 @@ +;; Test floating-point literal parsing. + +(module + ;; f32 special values + (func (export "f32.nan") (result i32) (i32.reinterpret/f32 (f32.const nan))) + (func (export "f32.positive_nan") (result i32) (i32.reinterpret/f32 (f32.const +nan))) + (func (export "f32.negative_nan") (result i32) (i32.reinterpret/f32 (f32.const -nan))) + (func (export "f32.plain_nan") (result i32) (i32.reinterpret/f32 (f32.const nan:0x400000))) + (func (export "f32.informally_known_as_plain_snan") (result i32) (i32.reinterpret/f32 (f32.const nan:0x200000))) + (func (export "f32.all_ones_nan") (result i32) (i32.reinterpret/f32 (f32.const -nan:0x7fffff))) + (func (export "f32.misc_nan") (result i32) (i32.reinterpret/f32 (f32.const nan:0x012345))) + (func (export "f32.misc_positive_nan") (result i32) (i32.reinterpret/f32 (f32.const +nan:0x304050))) + (func (export "f32.misc_negative_nan") (result i32) (i32.reinterpret/f32 (f32.const -nan:0x2abcde))) + (func (export "f32.infinity") (result i32) (i32.reinterpret/f32 (f32.const inf))) + (func (export "f32.positive_infinity") (result i32) (i32.reinterpret/f32 (f32.const +inf))) + (func (export "f32.negative_infinity") (result i32) (i32.reinterpret/f32 (f32.const -inf))) + + ;; f32 numbers + (func (export "f32.zero") (result i32) (i32.reinterpret/f32 (f32.const 0x0.0p0))) + (func (export "f32.positive_zero") (result i32) (i32.reinterpret/f32 (f32.const +0x0.0p0))) + (func (export "f32.negative_zero") (result i32) (i32.reinterpret/f32 (f32.const -0x0.0p0))) + (func (export "f32.misc") (result i32) (i32.reinterpret/f32 (f32.const 0x1.921fb6p+2))) + (func (export "f32.min_positive") (result i32) (i32.reinterpret/f32 (f32.const 0x1p-149))) + (func (export "f32.min_normal") (result i32) (i32.reinterpret/f32 (f32.const 0x1p-126))) + (func (export "f32.max_finite") (result i32) (i32.reinterpret/f32 (f32.const 0x1.fffffep+127))) + (func (export "f32.max_subnormal") (result i32) (i32.reinterpret/f32 (f32.const 0x1.fffffcp-127))) + (func (export "f32.trailing_dot") (result i32) (i32.reinterpret/f32 (f32.const 0x1.p10))) + + ;; f32 in decimal format + (func (export "f32_dec.zero") (result i32) (i32.reinterpret/f32 (f32.const 0.0e0))) + (func (export "f32_dec.positive_zero") (result i32) (i32.reinterpret/f32 (f32.const +0.0e0))) + (func (export "f32_dec.negative_zero") (result i32) (i32.reinterpret/f32 (f32.const -0.0e0))) + (func (export "f32_dec.misc") (result i32) (i32.reinterpret/f32 (f32.const 6.28318548202514648))) + (func (export "f32_dec.min_positive") (result i32) (i32.reinterpret/f32 (f32.const 1.4013e-45))) + (func (export "f32_dec.min_normal") (result i32) (i32.reinterpret/f32 (f32.const 1.1754944e-38))) + (func (export "f32_dec.max_subnormal") (result i32) (i32.reinterpret/f32 (f32.const 1.1754942e-38))) + (func (export "f32_dec.max_finite") (result i32) (i32.reinterpret/f32 (f32.const 3.4028234e+38))) + (func (export "f32_dec.trailing_dot") (result i32) (i32.reinterpret/f32 (f32.const 1.e10))) + + ;; https://twitter.com/Archivd/status/994637336506912768 + (func (export "f32_dec.root_beer_float") (result i32) (i32.reinterpret/f32 (f32.const 1.000000119))) + + ;; f64 special values + (func (export "f64.nan") (result i64) (i64.reinterpret/f64 (f64.const nan))) + (func (export "f64.positive_nan") (result i64) (i64.reinterpret/f64 (f64.const +nan))) + (func (export "f64.negative_nan") (result i64) (i64.reinterpret/f64 (f64.const -nan))) + (func (export "f64.plain_nan") (result i64) (i64.reinterpret/f64 (f64.const nan:0x8000000000000))) + (func (export "f64.informally_known_as_plain_snan") (result i64) (i64.reinterpret/f64 (f64.const nan:0x4000000000000))) + (func (export "f64.all_ones_nan") (result i64) (i64.reinterpret/f64 (f64.const -nan:0xfffffffffffff))) + (func (export "f64.misc_nan") (result i64) (i64.reinterpret/f64 (f64.const nan:0x0123456789abc))) + (func (export "f64.misc_positive_nan") (result i64) (i64.reinterpret/f64 (f64.const +nan:0x3040506070809))) + (func (export "f64.misc_negative_nan") (result i64) (i64.reinterpret/f64 (f64.const -nan:0x2abcdef012345))) + (func (export "f64.infinity") (result i64) (i64.reinterpret/f64 (f64.const inf))) + (func (export "f64.positive_infinity") (result i64) (i64.reinterpret/f64 (f64.const +inf))) + (func (export "f64.negative_infinity") (result i64) (i64.reinterpret/f64 (f64.const -inf))) + + ;; f64 numbers + (func (export "f64.zero") (result i64) (i64.reinterpret/f64 (f64.const 0x0.0p0))) + (func (export "f64.positive_zero") (result i64) (i64.reinterpret/f64 (f64.const +0x0.0p0))) + (func (export "f64.negative_zero") (result i64) (i64.reinterpret/f64 (f64.const -0x0.0p0))) + (func (export "f64.misc") (result i64) (i64.reinterpret/f64 (f64.const 0x1.921fb54442d18p+2))) + (func (export "f64.min_positive") (result i64) (i64.reinterpret/f64 (f64.const 0x0.0000000000001p-1022))) + (func (export "f64.min_normal") (result i64) (i64.reinterpret/f64 (f64.const 0x1p-1022))) + (func (export "f64.max_subnormal") (result i64) (i64.reinterpret/f64 (f64.const 0x0.fffffffffffffp-1022))) + (func (export "f64.max_finite") (result i64) (i64.reinterpret/f64 (f64.const 0x1.fffffffffffffp+1023))) + (func (export "f64.trailing_dot") (result i64) (i64.reinterpret/f64 (f64.const 0x1.p100))) + + ;; f64 numbers in decimal format + (func (export "f64_dec.zero") (result i64) (i64.reinterpret/f64 (f64.const 0.0e0))) + (func (export "f64_dec.positive_zero") (result i64) (i64.reinterpret/f64 (f64.const +0.0e0))) + (func (export "f64_dec.negative_zero") (result i64) (i64.reinterpret/f64 (f64.const -0.0e0))) + (func (export "f64_dec.misc") (result i64) (i64.reinterpret/f64 (f64.const 6.28318530717958623))) + (func (export "f64_dec.min_positive") (result i64) (i64.reinterpret/f64 (f64.const 4.94066e-324))) + (func (export "f64_dec.min_normal") (result i64) (i64.reinterpret/f64 (f64.const 2.2250738585072012e-308))) + (func (export "f64_dec.max_subnormal") (result i64) (i64.reinterpret/f64 (f64.const 2.2250738585072011e-308))) + (func (export "f64_dec.max_finite") (result i64) (i64.reinterpret/f64 (f64.const 1.7976931348623157e+308))) + (func (export "f64_dec.trailing_dot") (result i64) (i64.reinterpret/f64 (f64.const 1.e100))) + + ;; https://twitter.com/Archivd/status/994637336506912768 + (func (export "f64_dec.root_beer_float") (result i64) (i64.reinterpret/f64 (f64.const 1.000000119))) + + (func (export "f32-dec-sep1") (result f32) (f32.const 1_000_000)) + (func (export "f32-dec-sep2") (result f32) (f32.const 1_0_0_0)) + (func (export "f32-dec-sep3") (result f32) (f32.const 100_3.141_592)) + (func (export "f32-dec-sep4") (result f32) (f32.const 99e+1_3)) + (func (export "f32-dec-sep5") (result f32) (f32.const 122_000.11_3_54E0_2_3)) + (func (export "f32-hex-sep1") (result f32) (f32.const 0xa_0f_00_99)) + (func (export "f32-hex-sep2") (result f32) (f32.const 0x1_a_A_0_f)) + (func (export "f32-hex-sep3") (result f32) (f32.const 0xa0_ff.f141_a59a)) + (func (export "f32-hex-sep4") (result f32) (f32.const 0xf0P+1_3)) + (func (export "f32-hex-sep5") (result f32) (f32.const 0x2a_f00a.1f_3_eep2_3)) + + (func (export "f64-dec-sep1") (result f64) (f64.const 1_000_000)) + (func (export "f64-dec-sep2") (result f64) (f64.const 1_0_0_0)) + (func (export "f64-dec-sep3") (result f64) (f64.const 100_3.141_592)) + (func (export "f64-dec-sep4") (result f64) (f64.const 99e-1_23)) + (func (export "f64-dec-sep5") (result f64) (f64.const 122_000.11_3_54e0_2_3)) + (func (export "f64-hex-sep1") (result f64) (f64.const 0xa_f00f_0000_9999)) + (func (export "f64-hex-sep2") (result f64) (f64.const 0x1_a_A_0_f)) + (func (export "f64-hex-sep3") (result f64) (f64.const 0xa0_ff.f141_a59a)) + (func (export "f64-hex-sep4") (result f64) (f64.const 0xf0P+1_3)) + (func (export "f64-hex-sep5") (result f64) (f64.const 0x2a_f00a.1f_3_eep2_3)) +) + +(assert_return (invoke "f32.nan") (i32.const 0x7fc00000)) +(assert_return (invoke "f32.positive_nan") (i32.const 0x7fc00000)) +(assert_return (invoke "f32.negative_nan") (i32.const 0xffc00000)) +(assert_return (invoke "f32.plain_nan") (i32.const 0x7fc00000)) +(assert_return (invoke "f32.informally_known_as_plain_snan") (i32.const 0x7fa00000)) +(assert_return (invoke "f32.all_ones_nan") (i32.const 0xffffffff)) +(assert_return (invoke "f32.misc_nan") (i32.const 0x7f812345)) +(assert_return (invoke "f32.misc_positive_nan") (i32.const 0x7fb04050)) +(assert_return (invoke "f32.misc_negative_nan") (i32.const 0xffaabcde)) +(assert_return (invoke "f32.infinity") (i32.const 0x7f800000)) +(assert_return (invoke "f32.positive_infinity") (i32.const 0x7f800000)) +(assert_return (invoke "f32.negative_infinity") (i32.const 0xff800000)) +(assert_return (invoke "f32.zero") (i32.const 0)) +(assert_return (invoke "f32.positive_zero") (i32.const 0)) +(assert_return (invoke "f32.negative_zero") (i32.const 0x80000000)) +(assert_return (invoke "f32.misc") (i32.const 0x40c90fdb)) +(assert_return (invoke "f32.min_positive") (i32.const 1)) +(assert_return (invoke "f32.min_normal") (i32.const 0x800000)) +(assert_return (invoke "f32.max_subnormal") (i32.const 0x7fffff)) +(assert_return (invoke "f32.max_finite") (i32.const 0x7f7fffff)) +(assert_return (invoke "f32.trailing_dot") (i32.const 0x44800000)) +(assert_return (invoke "f32_dec.zero") (i32.const 0)) +(assert_return (invoke "f32_dec.positive_zero") (i32.const 0)) +(assert_return (invoke "f32_dec.negative_zero") (i32.const 0x80000000)) +(assert_return (invoke "f32_dec.misc") (i32.const 0x40c90fdb)) +(assert_return (invoke "f32_dec.min_positive") (i32.const 1)) +(assert_return (invoke "f32_dec.min_normal") (i32.const 0x800000)) +(assert_return (invoke "f32_dec.max_subnormal") (i32.const 0x7fffff)) +(assert_return (invoke "f32_dec.max_finite") (i32.const 0x7f7fffff)) +(assert_return (invoke "f32_dec.trailing_dot") (i32.const 0x501502f9)) +(assert_return (invoke "f32_dec.root_beer_float") (i32.const 0x3f800001)) + +(assert_return (invoke "f64.nan") (i64.const 0x7ff8000000000000)) +(assert_return (invoke "f64.positive_nan") (i64.const 0x7ff8000000000000)) +(assert_return (invoke "f64.negative_nan") (i64.const 0xfff8000000000000)) +(assert_return (invoke "f64.plain_nan") (i64.const 0x7ff8000000000000)) +(assert_return (invoke "f64.informally_known_as_plain_snan") (i64.const 0x7ff4000000000000)) +(assert_return (invoke "f64.all_ones_nan") (i64.const 0xffffffffffffffff)) +(assert_return (invoke "f64.misc_nan") (i64.const 0x7ff0123456789abc)) +(assert_return (invoke "f64.misc_positive_nan") (i64.const 0x7ff3040506070809)) +(assert_return (invoke "f64.misc_negative_nan") (i64.const 0xfff2abcdef012345)) +(assert_return (invoke "f64.infinity") (i64.const 0x7ff0000000000000)) +(assert_return (invoke "f64.positive_infinity") (i64.const 0x7ff0000000000000)) +(assert_return (invoke "f64.negative_infinity") (i64.const 0xfff0000000000000)) +(assert_return (invoke "f64.zero") (i64.const 0)) +(assert_return (invoke "f64.positive_zero") (i64.const 0)) +(assert_return (invoke "f64.negative_zero") (i64.const 0x8000000000000000)) +(assert_return (invoke "f64.misc") (i64.const 0x401921fb54442d18)) +(assert_return (invoke "f64.min_positive") (i64.const 1)) +(assert_return (invoke "f64.min_normal") (i64.const 0x10000000000000)) +(assert_return (invoke "f64.max_subnormal") (i64.const 0xfffffffffffff)) +(assert_return (invoke "f64.max_finite") (i64.const 0x7fefffffffffffff)) +(assert_return (invoke "f64.trailing_dot") (i64.const 0x4630000000000000)) +(assert_return (invoke "f64_dec.zero") (i64.const 0)) +(assert_return (invoke "f64_dec.positive_zero") (i64.const 0)) +(assert_return (invoke "f64_dec.negative_zero") (i64.const 0x8000000000000000)) +(assert_return (invoke "f64_dec.misc") (i64.const 0x401921fb54442d18)) +(assert_return (invoke "f64_dec.min_positive") (i64.const 1)) +(assert_return (invoke "f64_dec.min_normal") (i64.const 0x10000000000000)) +(assert_return (invoke "f64_dec.max_subnormal") (i64.const 0xfffffffffffff)) +(assert_return (invoke "f64_dec.max_finite") (i64.const 0x7fefffffffffffff)) +(assert_return (invoke "f64_dec.trailing_dot") (i64.const 0x54b249ad2594c37d)) +(assert_return (invoke "f64_dec.root_beer_float") (i64.const 0x3ff000001ff19e24)) + +(assert_return (invoke "f32-dec-sep1") (f32.const 1000000)) +(assert_return (invoke "f32-dec-sep2") (f32.const 1000)) +(assert_return (invoke "f32-dec-sep3") (f32.const 1003.141592)) +(assert_return (invoke "f32-dec-sep4") (f32.const 99e+13)) +(assert_return (invoke "f32-dec-sep5") (f32.const 122000.11354e23)) +(assert_return (invoke "f32-hex-sep1") (f32.const 0xa0f0099)) +(assert_return (invoke "f32-hex-sep2") (f32.const 0x1aa0f)) +(assert_return (invoke "f32-hex-sep3") (f32.const 0xa0ff.f141a59a)) +(assert_return (invoke "f32-hex-sep4") (f32.const 0xf0P+13)) +(assert_return (invoke "f32-hex-sep5") (f32.const 0x2af00a.1f3eep23)) + +(assert_return (invoke "f64-dec-sep1") (f64.const 1000000)) +(assert_return (invoke "f64-dec-sep2") (f64.const 1000)) +(assert_return (invoke "f64-dec-sep3") (f64.const 1003.141592)) +(assert_return (invoke "f64-dec-sep4") (f64.const 99e-123)) +(assert_return (invoke "f64-dec-sep5") (f64.const 122000.11354e23)) +(assert_return (invoke "f64-hex-sep1") (f64.const 0xaf00f00009999)) +(assert_return (invoke "f64-hex-sep2") (f64.const 0x1aa0f)) +(assert_return (invoke "f64-hex-sep3") (f64.const 0xa0ff.f141a59a)) +(assert_return (invoke "f64-hex-sep4") (f64.const 0xf0P+13)) +(assert_return (invoke "f64-hex-sep5") (f64.const 0x2af00a.1f3eep23)) + +;; Test parsing a float from binary +(module binary + ;; (func (export "4294967249") (result f64) (f64.const 4294967249)) + "\00\61\73\6d\01\00\00\00\01\85\80\80\80\00\01\60" + "\00\01\7c\03\82\80\80\80\00\01\00\07\8e\80\80\80" + "\00\01\0a\34\32\39\34\39\36\37\32\34\39\00\00\0a" + "\91\80\80\80\00\01\8b\80\80\80\00\00\44\00\00\20" + "\fa\ff\ff\ef\41\0b" +) + +(assert_return (invoke "4294967249") (f64.const 4294967249)) + +(assert_malformed + (module quote "(global f32 (f32.const _100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const +_100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const -_100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 99_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1__000))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const _1.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1.0_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1_.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1._0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const _1e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1e1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1_e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1e_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const _1.0e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1.0e1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1.0_e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1.0e_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1.0e+_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 1.0e_+1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const _0x100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0_x100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x_100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x00_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0xff__ffff))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x_1.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1.0_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1_.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1._0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x_1p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1p1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1_p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1p_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x_1.0p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1.0p1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1.0_p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1.0p_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1.0p+_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f32 (f32.const 0x1.0p_+1))") + "unknown operator" +) + +(assert_malformed + (module quote "(global f64 (f64.const _100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const +_100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const -_100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 99_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1__000))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const _1.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1.0_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1_.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1._0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const _1e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1e1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1_e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1e_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const _1.0e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1.0e1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1.0_e1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1.0e_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1.0e+_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 1.0e_+1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const _0x100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0_x100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x_100))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x00_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0xff__ffff))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x_1.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1.0_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1_.0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1._0))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x_1p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1p1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1_p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1p_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x_1.0p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1.0p1_))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1.0_p1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1.0p_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1.0p+_1))") + "unknown operator" +) +(assert_malformed + (module quote "(global f64 (f64.const 0x1.0p_+1))") + "unknown operator" +) diff --git a/spectests/return_.wast b/spectests/return_.wast new file mode 100644 index 000000000..32eee8542 --- /dev/null +++ b/spectests/return_.wast @@ -0,0 +1,312 @@ +;; Test `return` operator + +(module + ;; Auxiliary definition + (func $dummy) + + (func (export "type-i32") (drop (i32.ctz (return)))) + (func (export "type-i64") (drop (i64.ctz (return)))) + (func (export "type-f32") (drop (f32.neg (return)))) + (func (export "type-f64") (drop (f64.neg (return)))) + + (func (export "type-i32-value") (result i32) + (block (result i32) (i32.ctz (return (i32.const 1)))) + ) + (func (export "type-i64-value") (result i64) + (block (result i64) (i64.ctz (return (i64.const 2)))) + ) + (func (export "type-f32-value") (result f32) + (block (result f32) (f32.neg (return (f32.const 3)))) + ) + (func (export "type-f64-value") (result f64) + (block (result f64) (f64.neg (return (f64.const 4)))) + ) + + (func (export "nullary") (return)) + (func (export "unary") (result f64) (return (f64.const 3))) + + (func (export "as-func-first") (result i32) + (return (i32.const 1)) (i32.const 2) + ) + (func (export "as-func-mid") (result i32) + (call $dummy) (return (i32.const 2)) (i32.const 3) + ) + (func (export "as-func-last") + (nop) (call $dummy) (return) + ) + (func (export "as-func-value") (result i32) + (nop) (call $dummy) (return (i32.const 3)) + ) + + (func (export "as-block-first") + (block (return) (call $dummy)) + ) + (func (export "as-block-mid") + (block (call $dummy) (return) (call $dummy)) + ) + (func (export "as-block-last") + (block (nop) (call $dummy) (return)) + ) + (func (export "as-block-value") (result i32) + (block (result i32) (nop) (call $dummy) (return (i32.const 2))) + ) + + (func (export "as-loop-first") (result i32) + (loop (result i32) (return (i32.const 3)) (i32.const 2)) + ) + (func (export "as-loop-mid") (result i32) + (loop (result i32) (call $dummy) (return (i32.const 4)) (i32.const 2)) + ) + (func (export "as-loop-last") (result i32) + (loop (result i32) (nop) (call $dummy) (return (i32.const 5))) + ) + + (func (export "as-br-value") (result i32) + (block (result i32) (br 0 (return (i32.const 9)))) + ) + + (func (export "as-br_if-cond") + (block (br_if 0 (return))) + ) + (func (export "as-br_if-value") (result i32) + (block (result i32) + (drop (br_if 0 (return (i32.const 8)) (i32.const 1))) (i32.const 7) + ) + ) + (func (export "as-br_if-value-cond") (result i32) + (block (result i32) + (drop (br_if 0 (i32.const 6) (return (i32.const 9)))) (i32.const 7) + ) + ) + + (func (export "as-br_table-index") (result i64) + (block (br_table 0 0 0 (return (i64.const 9)))) (i64.const -1) + ) + (func (export "as-br_table-value") (result i32) + (block (result i32) + (br_table 0 0 0 (return (i32.const 10)) (i32.const 1)) (i32.const 7) + ) + ) + (func (export "as-br_table-value-index") (result i32) + (block (result i32) + (br_table 0 0 (i32.const 6) (return (i32.const 11))) (i32.const 7) + ) + ) + + (func (export "as-return-value") (result i64) + (return (return (i64.const 7))) + ) + + (func (export "as-if-cond") (result i32) + (if (result i32) + (return (i32.const 2)) (then (i32.const 0)) (else (i32.const 1)) + ) + ) + (func (export "as-if-then") (param i32 i32) (result i32) + (if (result i32) + (get_local 0) (then (return (i32.const 3))) (else (get_local 1)) + ) + ) + (func (export "as-if-else") (param i32 i32) (result i32) + (if (result i32) + (get_local 0) (then (get_local 1)) (else (return (i32.const 4))) + ) + ) + + (func (export "as-select-first") (param i32 i32) (result i32) + (select (return (i32.const 5)) (get_local 0) (get_local 1)) + ) + (func (export "as-select-second") (param i32 i32) (result i32) + (select (get_local 0) (return (i32.const 6)) (get_local 1)) + ) + (func (export "as-select-cond") (result i32) + (select (i32.const 0) (i32.const 1) (return (i32.const 7))) + ) + + (func $f (param i32 i32 i32) (result i32) (i32.const -1)) + (func (export "as-call-first") (result i32) + (call $f (return (i32.const 12)) (i32.const 2) (i32.const 3)) + ) + (func (export "as-call-mid") (result i32) + (call $f (i32.const 1) (return (i32.const 13)) (i32.const 3)) + ) + (func (export "as-call-last") (result i32) + (call $f (i32.const 1) (i32.const 2) (return (i32.const 14))) + ) + + (type $sig (func (param i32 i32 i32) (result i32))) + (table anyfunc (elem $f)) + (func (export "as-call_indirect-func") (result i32) + (call_indirect (type $sig) + (return (i32.const 20)) (i32.const 1) (i32.const 2) (i32.const 3) + ) + ) + (func (export "as-call_indirect-first") (result i32) + (call_indirect (type $sig) + (i32.const 0) (return (i32.const 21)) (i32.const 2) (i32.const 3) + ) + ) + (func (export "as-call_indirect-mid") (result i32) + (call_indirect (type $sig) + (i32.const 0) (i32.const 1) (return (i32.const 22)) (i32.const 3) + ) + ) + (func (export "as-call_indirect-last") (result i32) + (call_indirect (type $sig) + (i32.const 0) (i32.const 1) (i32.const 2) (return (i32.const 23)) + ) + ) + + (func (export "as-set_local-value") (result i32) (local f32) + (set_local 0 (return (i32.const 17))) (i32.const -1) + ) + + (memory 1) + (func (export "as-load-address") (result f32) + (f32.load (return (f32.const 1.7))) + ) + (func (export "as-loadN-address") (result i64) + (i64.load8_s (return (i64.const 30))) + ) + + (func (export "as-store-address") (result i32) + (f64.store (return (i32.const 30)) (f64.const 7)) (i32.const -1) + ) + (func (export "as-store-value") (result i32) + (i64.store (i32.const 2) (return (i32.const 31))) (i32.const -1) + ) + + (func (export "as-storeN-address") (result i32) + (i32.store8 (return (i32.const 32)) (i32.const 7)) (i32.const -1) + ) + (func (export "as-storeN-value") (result i32) + (i64.store16 (i32.const 2) (return (i32.const 33))) (i32.const -1) + ) + + (func (export "as-unary-operand") (result f32) + (f32.neg (return (f32.const 3.4))) + ) + + (func (export "as-binary-left") (result i32) + (i32.add (return (i32.const 3)) (i32.const 10)) + ) + (func (export "as-binary-right") (result i64) + (i64.sub (i64.const 10) (return (i64.const 45))) + ) + + (func (export "as-test-operand") (result i32) + (i32.eqz (return (i32.const 44))) + ) + + (func (export "as-compare-left") (result i32) + (f64.le (return (i32.const 43)) (f64.const 10)) + ) + (func (export "as-compare-right") (result i32) + (f32.ne (f32.const 10) (return (i32.const 42))) + ) + + (func (export "as-convert-operand") (result i32) + (i32.wrap/i64 (return (i32.const 41))) + ) + + (func (export "as-memory.grow-size") (result i32) + (memory.grow (return (i32.const 40))) + ) +) + +(assert_return (invoke "type-i32")) +(assert_return (invoke "type-i64")) +(assert_return (invoke "type-f32")) +(assert_return (invoke "type-f64")) + +(assert_return (invoke "type-i32-value") (i32.const 1)) +(assert_return (invoke "type-i64-value") (i64.const 2)) +(assert_return (invoke "type-f32-value") (f32.const 3)) +(assert_return (invoke "type-f64-value") (f64.const 4)) + +(assert_return (invoke "nullary")) +(assert_return (invoke "unary") (f64.const 3)) + +(assert_return (invoke "as-func-first") (i32.const 1)) +(assert_return (invoke "as-func-mid") (i32.const 2)) +(assert_return (invoke "as-func-last")) +(assert_return (invoke "as-func-value") (i32.const 3)) + +(assert_return (invoke "as-block-first")) +(assert_return (invoke "as-block-mid")) +(assert_return (invoke "as-block-last")) +(assert_return (invoke "as-block-value") (i32.const 2)) + +(assert_return (invoke "as-loop-first") (i32.const 3)) +(assert_return (invoke "as-loop-mid") (i32.const 4)) +(assert_return (invoke "as-loop-last") (i32.const 5)) + +(assert_return (invoke "as-br-value") (i32.const 9)) + +(assert_return (invoke "as-br_if-cond")) +(assert_return (invoke "as-br_if-value") (i32.const 8)) +(assert_return (invoke "as-br_if-value-cond") (i32.const 9)) + +(assert_return (invoke "as-br_table-index") (i64.const 9)) +(assert_return (invoke "as-br_table-value") (i32.const 10)) +(assert_return (invoke "as-br_table-value-index") (i32.const 11)) + +(assert_return (invoke "as-return-value") (i64.const 7)) + +(assert_return (invoke "as-if-cond") (i32.const 2)) +(assert_return (invoke "as-if-then" (i32.const 1) (i32.const 6)) (i32.const 3)) +(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6)) +(assert_return (invoke "as-if-else" (i32.const 0) (i32.const 6)) (i32.const 4)) +(assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6)) + +(assert_return (invoke "as-select-first" (i32.const 0) (i32.const 6)) (i32.const 5)) +(assert_return (invoke "as-select-first" (i32.const 1) (i32.const 6)) (i32.const 5)) +(assert_return (invoke "as-select-second" (i32.const 0) (i32.const 6)) (i32.const 6)) +(assert_return (invoke "as-select-second" (i32.const 1) (i32.const 6)) (i32.const 6)) +(assert_return (invoke "as-select-cond") (i32.const 7)) + +(assert_return (invoke "as-call-first") (i32.const 12)) +(assert_return (invoke "as-call-mid") (i32.const 13)) +(assert_return (invoke "as-call-last") (i32.const 14)) + +(assert_return (invoke "as-call_indirect-func") (i32.const 20)) +(assert_return (invoke "as-call_indirect-first") (i32.const 21)) +(assert_return (invoke "as-call_indirect-mid") (i32.const 22)) +(assert_return (invoke "as-call_indirect-last") (i32.const 23)) + +(assert_return (invoke "as-set_local-value") (i32.const 17)) + +(assert_return (invoke "as-load-address") (f32.const 1.7)) +(assert_return (invoke "as-loadN-address") (i64.const 30)) + +(assert_return (invoke "as-store-address") (i32.const 30)) +(assert_return (invoke "as-store-value") (i32.const 31)) +(assert_return (invoke "as-storeN-address") (i32.const 32)) +(assert_return (invoke "as-storeN-value") (i32.const 33)) + +(assert_return (invoke "as-unary-operand") (f32.const 3.4)) + +(assert_return (invoke "as-binary-left") (i32.const 3)) +(assert_return (invoke "as-binary-right") (i64.const 45)) + +(assert_return (invoke "as-test-operand") (i32.const 44)) + +(assert_return (invoke "as-compare-left") (i32.const 43)) +(assert_return (invoke "as-compare-right") (i32.const 42)) + +(assert_return (invoke "as-convert-operand") (i32.const 41)) + +(assert_return (invoke "as-memory.grow-size") (i32.const 40)) + +(assert_invalid + (module (func $type-value-empty-vs-num (result f64) (return))) + "type mismatch" +) +(assert_invalid + (module (func $type-value-void-vs-num (result f64) (return (nop)))) + "type mismatch" +) +(assert_invalid + (module (func $type-value-num-vs-num (result f64) (return (i64.const 1)))) + "type mismatch" +) diff --git a/spectests/select.wast b/spectests/select.wast new file mode 100644 index 000000000..4dfa45612 --- /dev/null +++ b/spectests/select.wast @@ -0,0 +1,67 @@ +(module + (func (export "select_i32") (param $lhs i32) (param $rhs i32) (param $cond i32) (result i32) + (select (get_local $lhs) (get_local $rhs) (get_local $cond))) + + (func (export "select_i64") (param $lhs i64) (param $rhs i64) (param $cond i32) (result i64) + (select (get_local $lhs) (get_local $rhs) (get_local $cond))) + + (func (export "select_f32") (param $lhs f32) (param $rhs f32) (param $cond i32) (result f32) + (select (get_local $lhs) (get_local $rhs) (get_local $cond))) + + (func (export "select_f64") (param $lhs f64) (param $rhs f64) (param $cond i32) (result f64) + (select (get_local $lhs) (get_local $rhs) (get_local $cond))) + + ;; Check that both sides of the select are evaluated + (func (export "select_trap_l") (param $cond i32) (result i32) + (select (unreachable) (i32.const 0) (get_local $cond)) + ) + (func (export "select_trap_r") (param $cond i32) (result i32) + (select (i32.const 0) (unreachable) (get_local $cond)) + ) + + (func (export "select_unreached") + (unreachable) (select) + (unreachable) (i32.const 0) (select) + (unreachable) (i32.const 0) (i32.const 0) (select) + (unreachable) (f32.const 0) (i32.const 0) (select) + (unreachable) + ) +) + +(assert_return (invoke "select_i32" (i32.const 1) (i32.const 2) (i32.const 1)) (i32.const 1)) +(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const 1)) (i64.const 2)) +(assert_return (invoke "select_f32" (f32.const 1) (f32.const 2) (i32.const 1)) (f32.const 1)) +(assert_return (invoke "select_f64" (f64.const 1) (f64.const 2) (i32.const 1)) (f64.const 1)) + +(assert_return (invoke "select_i32" (i32.const 1) (i32.const 2) (i32.const 0)) (i32.const 2)) +(assert_return (invoke "select_i32" (i32.const 2) (i32.const 1) (i32.const 0)) (i32.const 1)) +(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const -1)) (i64.const 2)) +(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const 0xf0f0f0f0)) (i64.const 2)) + +(assert_return (invoke "select_f32" (f32.const nan) (f32.const 1) (i32.const 1)) (f32.const nan)) +(assert_return (invoke "select_f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 1)) (f32.const nan:0x20304)) +(assert_return (invoke "select_f32" (f32.const nan) (f32.const 1) (i32.const 0)) (f32.const 1)) +(assert_return (invoke "select_f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 0)) (f32.const 1)) +(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan) (i32.const 1)) (f32.const 2)) +(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 1)) (f32.const 2)) +(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan) (i32.const 0)) (f32.const nan)) +(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 0)) (f32.const nan:0x20304)) + +(assert_return (invoke "select_f64" (f64.const nan) (f64.const 1) (i32.const 1)) (f64.const nan)) +(assert_return (invoke "select_f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 1)) (f64.const nan:0x20304)) +(assert_return (invoke "select_f64" (f64.const nan) (f64.const 1) (i32.const 0)) (f64.const 1)) +(assert_return (invoke "select_f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 0)) (f64.const 1)) +(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan) (i32.const 1)) (f64.const 2)) +(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 1)) (f64.const 2)) +(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan) (i32.const 0)) (f64.const nan)) +(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 0)) (f64.const nan:0x20304)) + +(assert_trap (invoke "select_trap_l" (i32.const 1)) "unreachable executed") +(assert_trap (invoke "select_trap_l" (i32.const 0)) "unreachable executed") +(assert_trap (invoke "select_trap_r" (i32.const 1)) "unreachable executed") +(assert_trap (invoke "select_trap_r" (i32.const 0)) "unreachable executed") + +(assert_invalid + (module (func $arity-0 (select (nop) (nop) (i32.const 1)))) + "type mismatch" +) diff --git a/spectests/switch.wast b/spectests/switch.wast new file mode 100644 index 000000000..829acc024 --- /dev/null +++ b/spectests/switch.wast @@ -0,0 +1,150 @@ +(module + ;; Statement switch + (func (export "stmt") (param $i i32) (result i32) + (local $j i32) + (set_local $j (i32.const 100)) + (block $switch + (block $7 + (block $default + (block $6 + (block $5 + (block $4 + (block $3 + (block $2 + (block $1 + (block $0 + (br_table $0 $1 $2 $3 $4 $5 $6 $7 $default + (get_local $i) + ) + ) ;; 0 + (return (get_local $i)) + ) ;; 1 + (nop) + ;; fallthrough + ) ;; 2 + ;; fallthrough + ) ;; 3 + (set_local $j (i32.sub (i32.const 0) (get_local $i))) + (br $switch) + ) ;; 4 + (br $switch) + ) ;; 5 + (set_local $j (i32.const 101)) + (br $switch) + ) ;; 6 + (set_local $j (i32.const 101)) + ;; fallthrough + ) ;; default + (set_local $j (i32.const 102)) + ) ;; 7 + ;; fallthrough + ) + (return (get_local $j)) + ) + + ;; Expression switch + (func (export "expr") (param $i i64) (result i64) + (local $j i64) + (set_local $j (i64.const 100)) + (return + (block $switch (result i64) + (block $7 + (block $default + (block $4 + (block $5 + (block $6 + (block $3 + (block $2 + (block $1 + (block $0 + (br_table $0 $1 $2 $3 $4 $5 $6 $7 $default + (i32.wrap/i64 (get_local $i)) + ) + ) ;; 0 + (return (get_local $i)) + ) ;; 1 + (nop) + ;; fallthrough + ) ;; 2 + ;; fallthrough + ) ;; 3 + (br $switch (i64.sub (i64.const 0) (get_local $i))) + ) ;; 6 + (set_local $j (i64.const 101)) + ;; fallthrough + ) ;; 4 + ;; fallthrough + ) ;; 5 + ;; fallthrough + ) ;; default + (br $switch (get_local $j)) + ) ;; 7 + (i64.const -5) + ) + ) + ) + + ;; Argument switch + (func (export "arg") (param $i i32) (result i32) + (return + (block $2 (result i32) + (i32.add (i32.const 10) + (block $1 (result i32) + (i32.add (i32.const 100) + (block $0 (result i32) + (i32.add (i32.const 1000) + (block $default (result i32) + (br_table $0 $1 $2 $default + (i32.mul (i32.const 2) (get_local $i)) + (i32.and (i32.const 3) (get_local $i)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + + ;; Corner cases + (func (export "corner") (result i32) + (block + (br_table 0 (i32.const 0)) + ) + (i32.const 1) + ) +) + +(assert_return (invoke "stmt" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "stmt" (i32.const 1)) (i32.const -1)) +(assert_return (invoke "stmt" (i32.const 2)) (i32.const -2)) +(assert_return (invoke "stmt" (i32.const 3)) (i32.const -3)) +(assert_return (invoke "stmt" (i32.const 4)) (i32.const 100)) +(assert_return (invoke "stmt" (i32.const 5)) (i32.const 101)) +(assert_return (invoke "stmt" (i32.const 6)) (i32.const 102)) +(assert_return (invoke "stmt" (i32.const 7)) (i32.const 100)) +(assert_return (invoke "stmt" (i32.const -10)) (i32.const 102)) + +(assert_return (invoke "expr" (i64.const 0)) (i64.const 0)) +(assert_return (invoke "expr" (i64.const 1)) (i64.const -1)) +(assert_return (invoke "expr" (i64.const 2)) (i64.const -2)) +(assert_return (invoke "expr" (i64.const 3)) (i64.const -3)) +(assert_return (invoke "expr" (i64.const 6)) (i64.const 101)) +(assert_return (invoke "expr" (i64.const 7)) (i64.const -5)) +(assert_return (invoke "expr" (i64.const -10)) (i64.const 100)) + +(assert_return (invoke "arg" (i32.const 0)) (i32.const 110)) +(assert_return (invoke "arg" (i32.const 1)) (i32.const 12)) +(assert_return (invoke "arg" (i32.const 2)) (i32.const 4)) +(assert_return (invoke "arg" (i32.const 3)) (i32.const 1116)) +(assert_return (invoke "arg" (i32.const 4)) (i32.const 118)) +(assert_return (invoke "arg" (i32.const 5)) (i32.const 20)) +(assert_return (invoke "arg" (i32.const 6)) (i32.const 12)) +(assert_return (invoke "arg" (i32.const 7)) (i32.const 1124)) +(assert_return (invoke "arg" (i32.const 8)) (i32.const 126)) + +(assert_return (invoke "corner") (i32.const 1)) + +(assert_invalid (module (func (br_table 3 (i32.const 0)))) "unknown label") diff --git a/spectests/tee_local.wast b/spectests/tee_local.wast new file mode 100644 index 000000000..000676319 --- /dev/null +++ b/spectests/tee_local.wast @@ -0,0 +1,235 @@ +;; Test `tee_local` operator + +(module + ;; Typing + + (func (export "type-local-i32") (result i32) (local i32) (tee_local 0 (i32.const 0))) + (func (export "type-local-i64") (result i64) (local i64) (tee_local 0 (i64.const 0))) + (func (export "type-local-f32") (result f32) (local f32) (tee_local 0 (f32.const 0))) + (func (export "type-local-f64") (result f64) (local f64) (tee_local 0 (f64.const 0))) + + (func (export "type-param-i32") (param i32) (result i32) (tee_local 0 (i32.const 10))) + (func (export "type-param-i64") (param i64) (result i64) (tee_local 0 (i64.const 11))) + (func (export "type-param-f32") (param f32) (result f32) (tee_local 0 (f32.const 11.1))) + (func (export "type-param-f64") (param f64) (result f64) (tee_local 0 (f64.const 12.2))) + + (func (export "type-mixed") (param i64 f32 f64 i32 i32) (local f32 i64 i64 f64) + (drop (i64.eqz (tee_local 0 (i64.const 0)))) + (drop (f32.neg (tee_local 1 (f32.const 0)))) + (drop (f64.neg (tee_local 2 (f64.const 0)))) + (drop (i32.eqz (tee_local 3 (i32.const 0)))) + (drop (i32.eqz (tee_local 4 (i32.const 0)))) + (drop (f32.neg (tee_local 5 (f32.const 0)))) + (drop (i64.eqz (tee_local 6 (i64.const 0)))) + (drop (i64.eqz (tee_local 7 (i64.const 0)))) + (drop (f64.neg (tee_local 8 (f64.const 0)))) + ) + + ;; Writing + + (func (export "write") (param i64 f32 f64 i32 i32) (result i64) (local f32 i64 i64 f64) + (drop (tee_local 1 (f32.const -0.3))) + (drop (tee_local 3 (i32.const 40))) + (drop (tee_local 4 (i32.const -7))) + (drop (tee_local 5 (f32.const 5.5))) + (drop (tee_local 6 (i64.const 6))) + (drop (tee_local 8 (f64.const 8))) + (i64.trunc_s/f64 + (f64.add + (f64.convert_u/i64 (get_local 0)) + (f64.add + (f64.promote/f32 (get_local 1)) + (f64.add + (get_local 2) + (f64.add + (f64.convert_u/i32 (get_local 3)) + (f64.add + (f64.convert_s/i32 (get_local 4)) + (f64.add + (f64.promote/f32 (get_local 5)) + (f64.add + (f64.convert_u/i64 (get_local 6)) + (f64.add + (f64.convert_u/i64 (get_local 7)) + (get_local 8) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + + ;; Result + + (func (export "result") (param i64 f32 f64 i32 i32) (result f64) + (local f32 i64 i64 f64) + (f64.add + (f64.convert_u/i64 (tee_local 0 (i64.const 1))) + (f64.add + (f64.promote/f32 (tee_local 1 (f32.const 2))) + (f64.add + (tee_local 2 (f64.const 3.3)) + (f64.add + (f64.convert_u/i32 (tee_local 3 (i32.const 4))) + (f64.add + (f64.convert_s/i32 (tee_local 4 (i32.const 5))) + (f64.add + (f64.promote/f32 (tee_local 5 (f32.const 5.5))) + (f64.add + (f64.convert_u/i64 (tee_local 6 (i64.const 6))) + (f64.add + (f64.convert_u/i64 (tee_local 7 (i64.const 0))) + (tee_local 8 (f64.const 8)) + ) + ) + ) + ) + ) + ) + ) + ) + ) +) + +(assert_return (invoke "type-local-i32") (i32.const 0)) +(assert_return (invoke "type-local-i64") (i64.const 0)) +(assert_return (invoke "type-local-f32") (f32.const 0)) +(assert_return (invoke "type-local-f64") (f64.const 0)) + +(assert_return (invoke "type-param-i32" (i32.const 2)) (i32.const 10)) +(assert_return (invoke "type-param-i64" (i64.const 3)) (i64.const 11)) +(assert_return (invoke "type-param-f32" (f32.const 4.4)) (f32.const 11.1)) +(assert_return (invoke "type-param-f64" (f64.const 5.5)) (f64.const 12.2)) + +(assert_return + (invoke "type-mixed" + (i64.const 1) (f32.const 2.2) (f64.const 3.3) (i32.const 4) (i32.const 5) + ) +) + +(assert_return + (invoke "write" + (i64.const 1) (f32.const 2) (f64.const 3.3) (i32.const 4) (i32.const 5) + ) + (i64.const 56) +) + +(assert_return + (invoke "result" + (i64.const -1) (f32.const -2) (f64.const -3.3) (i32.const -4) (i32.const -5) + ) + (f64.const 34.8) +) + + +;; Invalid typing of access to locals + +(assert_invalid + (module (func $type-local-num-vs-num (result i64) (local i32) (tee_local 0 (i32.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-local-num-vs-num (local f32) (i32.eqz (tee_local 0 (f32.const 0))))) + "type mismatch" +) +(assert_invalid + (module (func $type-local-num-vs-num (local f64 i64) (f64.neg (tee_local 1 (i64.const 0))))) + "type mismatch" +) + +(assert_invalid + (module (func $type-local-arg-void-vs-num (local i32) (tee_local 0 (nop)))) + "type mismatch" +) +(assert_invalid + (module (func $type-local-arg-num-vs-num (local i32) (tee_local 0 (f32.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-local-arg-num-vs-num (local f32) (tee_local 0 (f64.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-local-arg-num-vs-num (local f64 i64) (tee_local 1 (f64.const 0)))) + "type mismatch" +) + + +;; Invalid typing of access to parameters + +(assert_invalid + (module (func $type-param-num-vs-num (param i32) (result i64) (get_local 0))) + "type mismatch" +) +(assert_invalid + (module (func $type-param-num-vs-num (param f32) (i32.eqz (get_local 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-param-num-vs-num (param f64 i64) (f64.neg (get_local 1)))) + "type mismatch" +) + +(assert_invalid + (module (func $type-param-arg-void-vs-num (param i32) (tee_local 0 (nop)))) + "type mismatch" +) +(assert_invalid + (module (func $type-param-arg-num-vs-num (param i32) (tee_local 0 (f32.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-param-arg-num-vs-num (param f32) (tee_local 0 (f64.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-param-arg-num-vs-num (param f64 i64) (tee_local 1 (f64.const 0)))) + "type mismatch" +) + + +;; Invalid local index + +(assert_invalid + (module (func $unbound-local (local i32 i64) (get_local 3))) + "unknown local" +) +(assert_invalid + (module (func $large-local (local i32 i64) (get_local 14324343))) + "unknown local" +) + +(assert_invalid + (module (func $unbound-param (param i32 i64) (get_local 2))) + "unknown local" +) +(assert_invalid + (module (func $large-param (local i32 i64) (get_local 714324343))) + "unknown local" +) + +(assert_invalid + (module (func $unbound-mixed (param i32) (local i32 i64) (get_local 3))) + "unknown local" +) +(assert_invalid + (module (func $large-mixed (param i64) (local i32 i64) (get_local 214324343))) + "unknown local" +) + +(assert_invalid + (module (func $type-mixed-arg-num-vs-num (param f32) (local i32) (tee_local 1 (f32.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-mixed-arg-num-vs-num (param i64 i32) (local f32) (tee_local 1 (f32.const 0)))) + "type mismatch" +) +(assert_invalid + (module (func $type-mixed-arg-num-vs-num (param i64) (local f64 i64) (tee_local 1 (i64.const 0)))) + "type mismatch" +) diff --git a/src/build_spectests.rs b/src/build_spectests.rs index 89048369b..bb4b53e4c 100644 --- a/src/build_spectests.rs +++ b/src/build_spectests.rs @@ -15,7 +15,7 @@ static ENV_VAR: &str = "WASM_GENERATE_SPECTESTS"; static BANNER: &str = "// Rust test file autogenerated with cargo build (src/build_spectests.rs). // Please do NOT modify it by hand, as it will be reseted on next build.\n"; -const TESTS: [&str; 25] = [ +const TESTS: [&str; 31] = [ "spectests/address.wast", "spectests/align.wast", "spectests/block.wast", @@ -27,6 +27,7 @@ const TESTS: [&str; 25] = [ "spectests/call_indirect.wast", "spectests/const_.wast", "spectests/data.wast", + "spectests/endianness.wast", "spectests/exports.wast", "spectests/f32_.wast", "spectests/f32_bitwise.wast", @@ -34,12 +35,17 @@ const TESTS: [&str; 25] = [ "spectests/f64_.wast", "spectests/f64_bitwise.wast", "spectests/f64_cmp.wast", + "spectests/float_literals.wast", "spectests/func_ptrs.wast", "spectests/i32_.wast", "spectests/i64_.wast", "spectests/labels.wast", "spectests/memory.wast", + "spectests/return_.wast", + "spectests/select.wast", "spectests/set_local.wast", + "spectests/switch.wast", + "spectests/tee_local.wast", "spectests/types.wast", ]; diff --git a/src/spectests/endianness.rs b/src/spectests/endianness.rs new file mode 100644 index 000000000..c811e2efc --- /dev/null +++ b/src/spectests/endianness.rs @@ -0,0 +1,1114 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/endianness.wast +#![allow( + warnings, + dead_code +)] +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export}; +use super::_common::spectest_importobject; +use wabt::wat2wasm; + + +// Line 1 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32 i32))) + (type (;1;) (func (param i32 i64))) + (type (;2;) (func (param i32) (result i32))) + (type (;3;) (func (param i32) (result i64))) + (type (;4;) (func (param i64) (result i64))) + (type (;5;) (func (param f32) (result f32))) + (type (;6;) (func (param f64) (result f64))) + (func (;0;) (type 0) (param i32 i32) + get_local 0 + get_local 1 + i32.store8 + get_local 0 + i32.const 1 + i32.add + get_local 1 + i32.const 8 + i32.shr_u + i32.store8) + (func (;1;) (type 0) (param i32 i32) + get_local 0 + get_local 1 + call 0 + get_local 0 + i32.const 2 + i32.add + get_local 1 + i32.const 16 + i32.shr_u + call 0) + (func (;2;) (type 1) (param i32 i64) + get_local 0 + get_local 1 + i32.wrap/i64 + call 1 + get_local 0 + i32.const 4 + i32.add + get_local 1 + i64.const 32 + i64.shr_u + i32.wrap/i64 + call 1) + (func (;3;) (type 2) (param i32) (result i32) + get_local 0 + i32.load8_u + get_local 0 + i32.const 1 + i32.add + i32.load8_u + i32.const 8 + i32.shl + i32.or) + (func (;4;) (type 2) (param i32) (result i32) + get_local 0 + call 3 + get_local 0 + i32.const 2 + i32.add + call 3 + i32.const 16 + i32.shl + i32.or) + (func (;5;) (type 3) (param i32) (result i64) + get_local 0 + call 4 + i64.extend_u/i32 + get_local 0 + i32.const 4 + i32.add + call 4 + i64.extend_u/i32 + i64.const 32 + i64.shl + i64.or) + (func (;6;) (type 2) (param i32) (result i32) + i32.const 0 + get_local 0 + call 0 + i32.const 0 + i32.load16_s) + (func (;7;) (type 2) (param i32) (result i32) + i32.const 0 + get_local 0 + call 0 + i32.const 0 + i32.load16_u) + (func (;8;) (type 2) (param i32) (result i32) + i32.const 0 + get_local 0 + call 1 + i32.const 0 + i32.load) + (func (;9;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i32.wrap/i64 + call 0 + i32.const 0 + i64.load16_s) + (func (;10;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i32.wrap/i64 + call 0 + i32.const 0 + i64.load16_u) + (func (;11;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i32.wrap/i64 + call 1 + i32.const 0 + i64.load32_s) + (func (;12;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i32.wrap/i64 + call 1 + i32.const 0 + i64.load32_u) + (func (;13;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + call 2 + i32.const 0 + i64.load) + (func (;14;) (type 5) (param f32) (result f32) + i32.const 0 + get_local 0 + i32.reinterpret/f32 + call 1 + i32.const 0 + f32.load) + (func (;15;) (type 6) (param f64) (result f64) + i32.const 0 + get_local 0 + i64.reinterpret/f64 + call 2 + i32.const 0 + f64.load) + (func (;16;) (type 2) (param i32) (result i32) + i32.const 0 + get_local 0 + i32.store16 + i32.const 0 + call 3) + (func (;17;) (type 2) (param i32) (result i32) + i32.const 0 + get_local 0 + i32.store + i32.const 0 + call 4) + (func (;18;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i64.store16 + i32.const 0 + call 3 + i64.extend_u/i32) + (func (;19;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i64.store32 + i32.const 0 + call 4 + i64.extend_u/i32) + (func (;20;) (type 4) (param i64) (result i64) + i32.const 0 + get_local 0 + i64.store + i32.const 0 + call 5) + (func (;21;) (type 5) (param f32) (result f32) + i32.const 0 + get_local 0 + f32.store + i32.const 0 + call 4 + f32.reinterpret/i32) + (func (;22;) (type 6) (param f64) (result f64) + i32.const 0 + get_local 0 + f64.store + i32.const 0 + call 5 + f64.reinterpret/i64) + (memory (;0;) 1) + (export \"i32_load16_s\" (func 6)) + (export \"i32_load16_u\" (func 7)) + (export \"i32_load\" (func 8)) + (export \"i64_load16_s\" (func 9)) + (export \"i64_load16_u\" (func 10)) + (export \"i64_load32_s\" (func 11)) + (export \"i64_load32_u\" (func 12)) + (export \"i64_load\" (func 13)) + (export \"f32_load\" (func 14)) + (export \"f64_load\" (func 15)) + (export \"i32_store16\" (func 16)) + (export \"i32_store\" (func 17)) + (export \"i64_store16\" (func 18)) + (export \"i64_store32\" (func 19)) + (export \"i64_store\" (func 20)) + (export \"f32_store\" (func 21)) + (export \"f64_store\" (func 22))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 133 +fn l133_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l133_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i32, &vm_context); + assert_eq!(result, -1 as i32); +} + +// Line 134 +fn l134_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l134_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i32, &vm_context); + assert_eq!(result, -4242 as i32); +} + +// Line 135 +fn l135_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l135_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42 as i32, &vm_context); + assert_eq!(result, 42 as i32); +} + +// Line 136 +fn l136_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l136_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(12816 as i32, &vm_context); + assert_eq!(result, 12816 as i32); +} + +// Line 138 +fn l138_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l138_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i32, &vm_context); + assert_eq!(result, 65535 as i32); +} + +// Line 139 +fn l139_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l139_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i32, &vm_context); + assert_eq!(result, 61294 as i32); +} + +// Line 140 +fn l140_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l140_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42 as i32, &vm_context); + assert_eq!(result, 42 as i32); +} + +// Line 141 +fn l141_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l141_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(51966 as i32, &vm_context); + assert_eq!(result, 51966 as i32); +} + +// Line 143 +fn l143_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l143_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i32, &vm_context); + assert_eq!(result, -1 as i32); +} + +// Line 144 +fn l144_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l144_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-42424242 as i32, &vm_context); + assert_eq!(result, -42424242 as i32); +} + +// Line 145 +fn l145_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l145_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42424242 as i32, &vm_context); + assert_eq!(result, 42424242 as i32); +} + +// Line 146 +fn l146_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l146_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1414717974 as i32, &vm_context); + assert_eq!(result, -1414717974 as i32); +} + +// Line 148 +fn l148_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l148_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, -1 as i64); +} + +// Line 149 +fn l149_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l149_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i64, &vm_context); + assert_eq!(result, -4242 as i64); +} + +// Line 150 +fn l150_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l150_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42 as i64, &vm_context); + assert_eq!(result, 42 as i64); +} + +// Line 151 +fn l151_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l151_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(12816 as i64, &vm_context); + assert_eq!(result, 12816 as i64); +} + +// Line 153 +fn l153_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l153_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, 65535 as i64); +} + +// Line 154 +fn l154_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l154_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i64, &vm_context); + assert_eq!(result, 61294 as i64); +} + +// Line 155 +fn l155_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l155_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42 as i64, &vm_context); + assert_eq!(result, 42 as i64); +} + +// Line 156 +fn l156_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l156_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(51966 as i64, &vm_context); + assert_eq!(result, 51966 as i64); +} + +// Line 158 +fn l158_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l158_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, -1 as i64); +} + +// Line 159 +fn l159_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l159_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-42424242 as i64, &vm_context); + assert_eq!(result, -42424242 as i64); +} + +// Line 160 +fn l160_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l160_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42424242 as i64, &vm_context); + assert_eq!(result, 42424242 as i64); +} + +// Line 161 +fn l161_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l161_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(305419896 as i64, &vm_context); + assert_eq!(result, 305419896 as i64); +} + +// Line 163 +fn l163_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l163_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, 4294967295 as i64); +} + +// Line 164 +fn l164_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l164_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-42424242 as i64, &vm_context); + assert_eq!(result, 4252543054 as i64); +} + +// Line 165 +fn l165_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l165_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42424242 as i64, &vm_context); + assert_eq!(result, 42424242 as i64); +} + +// Line 166 +fn l166_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l166_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load32_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2880249322 as i64, &vm_context); + assert_eq!(result, 2880249322 as i64); +} + +// Line 168 +fn l168_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l168_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, -1 as i64); +} + +// Line 169 +fn l169_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l169_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-42424242 as i64, &vm_context); + assert_eq!(result, -42424242 as i64); +} + +// Line 170 +fn l170_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l170_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2880249322 as i64, &vm_context); + assert_eq!(result, 2880249322 as i64); +} + +// Line 171 +fn l171_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l171_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-6075977126246539798 as i64, &vm_context); + assert_eq!(result, -6075977126246539798 as i64); +} + +// Line 173 +fn l173_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l173_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1.0 as f32, &vm_context); + assert_eq!(result, -1.0 as f32); +} + +// Line 174 +fn l174_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l174_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0.01234 as f32, &vm_context); + assert_eq!(result, 0.01234 as f32); +} + +// Line 175 +fn l175_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l175_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(4242.4243 as f32, &vm_context); + assert_eq!(result, 4242.4243 as f32); +} + +// Line 176 +fn l176_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l176_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(340282350000000000000000000000000000000.0 as f32, &vm_context); + assert_eq!(result, 340282350000000000000000000000000000000.0 as f32); +} + +// Line 178 +fn l178_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l178_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1.0 as f64, &vm_context); + assert_eq!(result, -1.0 as f64); +} + +// Line 179 +fn l179_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l179_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1234.56789 as f64, &vm_context); + assert_eq!(result, 1234.56789 as f64); +} + +// Line 180 +fn l180_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l180_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(424242.424242 as f64, &vm_context); + assert_eq!(result, 424242.424242 as f64); +} + +// Line 181 +fn l181_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l181_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 as f64, &vm_context); + assert_eq!(result, 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 as f64); +} + +// Line 184 +fn l184_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l184_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i32, &vm_context); + assert_eq!(result, 65535 as i32); +} + +// Line 185 +fn l185_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l185_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i32, &vm_context); + assert_eq!(result, 61294 as i32); +} + +// Line 186 +fn l186_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l186_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42 as i32, &vm_context); + assert_eq!(result, 42 as i32); +} + +// Line 187 +fn l187_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l187_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(51966 as i32, &vm_context); + assert_eq!(result, 51966 as i32); +} + +// Line 189 +fn l189_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l189_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i32, &vm_context); + assert_eq!(result, -1 as i32); +} + +// Line 190 +fn l190_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l190_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i32, &vm_context); + assert_eq!(result, -4242 as i32); +} + +// Line 191 +fn l191_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l191_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42424242 as i32, &vm_context); + assert_eq!(result, 42424242 as i32); +} + +// Line 192 +fn l192_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l192_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-559035650 as i32, &vm_context); + assert_eq!(result, -559035650 as i32); +} + +// Line 194 +fn l194_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l194_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, 65535 as i64); +} + +// Line 195 +fn l195_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l195_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i64, &vm_context); + assert_eq!(result, 61294 as i64); +} + +// Line 196 +fn l196_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l196_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42 as i64, &vm_context); + assert_eq!(result, 42 as i64); +} + +// Line 197 +fn l197_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l197_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store16") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(51966 as i64, &vm_context); + assert_eq!(result, 51966 as i64); +} + +// Line 199 +fn l199_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l199_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, 4294967295 as i64); +} + +// Line 200 +fn l200_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l200_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-4242 as i64, &vm_context); + assert_eq!(result, 4294963054 as i64); +} + +// Line 201 +fn l201_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l201_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(42424242 as i64, &vm_context); + assert_eq!(result, 42424242 as i64); +} + +// Line 202 +fn l202_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l202_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(3735931646 as i64, &vm_context); + assert_eq!(result, 3735931646 as i64); +} + +// Line 204 +fn l204_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l204_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, &vm_context); + assert_eq!(result, -1 as i64); +} + +// Line 205 +fn l205_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l205_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-42424242 as i64, &vm_context); + assert_eq!(result, -42424242 as i64); +} + +// Line 206 +fn l206_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l206_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2880249322 as i64, &vm_context); + assert_eq!(result, 2880249322 as i64); +} + +// Line 207 +fn l207_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l207_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("i64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-6075977126246539798 as i64, &vm_context); + assert_eq!(result, -6075977126246539798 as i64); +} + +// Line 209 +fn l209_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l209_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1.0 as f32, &vm_context); + assert_eq!(result, -1.0 as f32); +} + +// Line 210 +fn l210_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l210_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0.01234 as f32, &vm_context); + assert_eq!(result, 0.01234 as f32); +} + +// Line 211 +fn l211_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l211_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(4242.4243 as f32, &vm_context); + assert_eq!(result, 4242.4243 as f32); +} + +// Line 212 +fn l212_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l212_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(340282350000000000000000000000000000000.0 as f32, &vm_context); + assert_eq!(result, 340282350000000000000000000000000000000.0 as f32); +} + +// Line 214 +fn l214_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l214_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1.0 as f64, &vm_context); + assert_eq!(result, -1.0 as f64); +} + +// Line 215 +fn l215_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l215_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1234.56789 as f64, &vm_context); + assert_eq!(result, 1234.56789 as f64); +} + +// Line 216 +fn l216_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l216_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(424242.424242 as f64, &vm_context); + assert_eq!(result, 424242.424242 as f64); +} + +// Line 217 +fn l217_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l217_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_store") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 as f64, &vm_context); + assert_eq!(result, 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 as f64); +} + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l133_assert_return_invoke(&result_object, &vm_context); + l134_assert_return_invoke(&result_object, &vm_context); + l135_assert_return_invoke(&result_object, &vm_context); + l136_assert_return_invoke(&result_object, &vm_context); + l138_assert_return_invoke(&result_object, &vm_context); + l139_assert_return_invoke(&result_object, &vm_context); + l140_assert_return_invoke(&result_object, &vm_context); + l141_assert_return_invoke(&result_object, &vm_context); + l143_assert_return_invoke(&result_object, &vm_context); + l144_assert_return_invoke(&result_object, &vm_context); + l145_assert_return_invoke(&result_object, &vm_context); + l146_assert_return_invoke(&result_object, &vm_context); + l148_assert_return_invoke(&result_object, &vm_context); + l149_assert_return_invoke(&result_object, &vm_context); + l150_assert_return_invoke(&result_object, &vm_context); + l151_assert_return_invoke(&result_object, &vm_context); + l153_assert_return_invoke(&result_object, &vm_context); + l154_assert_return_invoke(&result_object, &vm_context); + l155_assert_return_invoke(&result_object, &vm_context); + l156_assert_return_invoke(&result_object, &vm_context); + l158_assert_return_invoke(&result_object, &vm_context); + l159_assert_return_invoke(&result_object, &vm_context); + l160_assert_return_invoke(&result_object, &vm_context); + l161_assert_return_invoke(&result_object, &vm_context); + l163_assert_return_invoke(&result_object, &vm_context); + l164_assert_return_invoke(&result_object, &vm_context); + l165_assert_return_invoke(&result_object, &vm_context); + l166_assert_return_invoke(&result_object, &vm_context); + l168_assert_return_invoke(&result_object, &vm_context); + l169_assert_return_invoke(&result_object, &vm_context); + l170_assert_return_invoke(&result_object, &vm_context); + l171_assert_return_invoke(&result_object, &vm_context); + l173_assert_return_invoke(&result_object, &vm_context); + l174_assert_return_invoke(&result_object, &vm_context); + l175_assert_return_invoke(&result_object, &vm_context); + l176_assert_return_invoke(&result_object, &vm_context); + l178_assert_return_invoke(&result_object, &vm_context); + l179_assert_return_invoke(&result_object, &vm_context); + l180_assert_return_invoke(&result_object, &vm_context); + l181_assert_return_invoke(&result_object, &vm_context); + l184_assert_return_invoke(&result_object, &vm_context); + l185_assert_return_invoke(&result_object, &vm_context); + l186_assert_return_invoke(&result_object, &vm_context); + l187_assert_return_invoke(&result_object, &vm_context); + l189_assert_return_invoke(&result_object, &vm_context); + l190_assert_return_invoke(&result_object, &vm_context); + l191_assert_return_invoke(&result_object, &vm_context); + l192_assert_return_invoke(&result_object, &vm_context); + l194_assert_return_invoke(&result_object, &vm_context); + l195_assert_return_invoke(&result_object, &vm_context); + l196_assert_return_invoke(&result_object, &vm_context); + l197_assert_return_invoke(&result_object, &vm_context); + l199_assert_return_invoke(&result_object, &vm_context); + l200_assert_return_invoke(&result_object, &vm_context); + l201_assert_return_invoke(&result_object, &vm_context); + l202_assert_return_invoke(&result_object, &vm_context); + l204_assert_return_invoke(&result_object, &vm_context); + l205_assert_return_invoke(&result_object, &vm_context); + l206_assert_return_invoke(&result_object, &vm_context); + l207_assert_return_invoke(&result_object, &vm_context); + l209_assert_return_invoke(&result_object, &vm_context); + l210_assert_return_invoke(&result_object, &vm_context); + l211_assert_return_invoke(&result_object, &vm_context); + l212_assert_return_invoke(&result_object, &vm_context); + l214_assert_return_invoke(&result_object, &vm_context); + l215_assert_return_invoke(&result_object, &vm_context); + l216_assert_return_invoke(&result_object, &vm_context); + l217_assert_return_invoke(&result_object, &vm_context); +} diff --git a/src/spectests/float_literals.rs b/src/spectests/float_literals.rs new file mode 100644 index 000000000..5bdba0a01 --- /dev/null +++ b/src/spectests/float_literals.rs @@ -0,0 +1,2044 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/float_literals.wast +#![allow( + warnings, + dead_code +)] +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export}; +use super::_common::spectest_importobject; +use wabt::wat2wasm; + + +// Line 3 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (type (;1;) (func (result i64))) + (type (;2;) (func (result f32))) + (type (;3;) (func (result f64))) + (func (;0;) (type 0) (result i32) + f32.const nan (;=nan;) + i32.reinterpret/f32) + (func (;1;) (type 0) (result i32) + f32.const nan (;=nan;) + i32.reinterpret/f32) + (func (;2;) (type 0) (result i32) + f32.const -nan (;=nan;) + i32.reinterpret/f32) + (func (;3;) (type 0) (result i32) + f32.const nan (;=nan;) + i32.reinterpret/f32) + (func (;4;) (type 0) (result i32) + f32.const nan:0x200000 (;=nan;) + i32.reinterpret/f32) + (func (;5;) (type 0) (result i32) + f32.const -nan:0x7fffff (;=nan;) + i32.reinterpret/f32) + (func (;6;) (type 0) (result i32) + f32.const nan:0x12345 (;=nan;) + i32.reinterpret/f32) + (func (;7;) (type 0) (result i32) + f32.const nan:0x304050 (;=nan;) + i32.reinterpret/f32) + (func (;8;) (type 0) (result i32) + f32.const -nan:0x2abcde (;=nan;) + i32.reinterpret/f32) + (func (;9;) (type 0) (result i32) + f32.const inf (;=inf;) + i32.reinterpret/f32) + (func (;10;) (type 0) (result i32) + f32.const inf (;=inf;) + i32.reinterpret/f32) + (func (;11;) (type 0) (result i32) + f32.const -inf (;=-inf;) + i32.reinterpret/f32) + (func (;12;) (type 0) (result i32) + f32.const 0x0p+0 (;=0;) + i32.reinterpret/f32) + (func (;13;) (type 0) (result i32) + f32.const 0x0p+0 (;=0;) + i32.reinterpret/f32) + (func (;14;) (type 0) (result i32) + f32.const -0x0p+0 (;=-0;) + i32.reinterpret/f32) + (func (;15;) (type 0) (result i32) + f32.const 0x1.921fb6p+2 (;=6.28319;) + i32.reinterpret/f32) + (func (;16;) (type 0) (result i32) + f32.const 0x1.p-149 (;=1.4013e-45;) + i32.reinterpret/f32) + (func (;17;) (type 0) (result i32) + f32.const 0x1p-126 (;=1.17549e-38;) + i32.reinterpret/f32) + (func (;18;) (type 0) (result i32) + f32.const 0x1.fffffep+127 (;=3.40282e+38;) + i32.reinterpret/f32) + (func (;19;) (type 0) (result i32) + f32.const 0x1.fffffcp-127 (;=1.17549e-38;) + i32.reinterpret/f32) + (func (;20;) (type 0) (result i32) + f32.const 0x1p+10 (;=1024;) + i32.reinterpret/f32) + (func (;21;) (type 0) (result i32) + f32.const 0x0p+0 (;=0;) + i32.reinterpret/f32) + (func (;22;) (type 0) (result i32) + f32.const 0x0p+0 (;=0;) + i32.reinterpret/f32) + (func (;23;) (type 0) (result i32) + f32.const -0x0p+0 (;=-0;) + i32.reinterpret/f32) + (func (;24;) (type 0) (result i32) + f32.const 0x1.921fb6p+2 (;=6.28319;) + i32.reinterpret/f32) + (func (;25;) (type 0) (result i32) + f32.const 0x1.p-149 (;=1.4013e-45;) + i32.reinterpret/f32) + (func (;26;) (type 0) (result i32) + f32.const 0x1p-126 (;=1.17549e-38;) + i32.reinterpret/f32) + (func (;27;) (type 0) (result i32) + f32.const 0x1.fffffcp-127 (;=1.17549e-38;) + i32.reinterpret/f32) + (func (;28;) (type 0) (result i32) + f32.const 0x1.fffffep+127 (;=3.40282e+38;) + i32.reinterpret/f32) + (func (;29;) (type 0) (result i32) + f32.const 0x1.2a05f2p+33 (;=1e+10;) + i32.reinterpret/f32) + (func (;30;) (type 0) (result i32) + f32.const 0x1.000002p+0 (;=1;) + i32.reinterpret/f32) + (func (;31;) (type 1) (result i64) + f64.const nan (;=nan;) + i64.reinterpret/f64) + (func (;32;) (type 1) (result i64) + f64.const nan (;=nan;) + i64.reinterpret/f64) + (func (;33;) (type 1) (result i64) + f64.const -nan (;=nan;) + i64.reinterpret/f64) + (func (;34;) (type 1) (result i64) + f64.const nan (;=nan;) + i64.reinterpret/f64) + (func (;35;) (type 1) (result i64) + f64.const nan:0x4000000000000 (;=nan;) + i64.reinterpret/f64) + (func (;36;) (type 1) (result i64) + f64.const -nan:0xfffffffffffff (;=nan;) + i64.reinterpret/f64) + (func (;37;) (type 1) (result i64) + f64.const nan:0x123456789abc (;=nan;) + i64.reinterpret/f64) + (func (;38;) (type 1) (result i64) + f64.const nan:0x3040506070809 (;=nan;) + i64.reinterpret/f64) + (func (;39;) (type 1) (result i64) + f64.const -nan:0x2abcdef012345 (;=nan;) + i64.reinterpret/f64) + (func (;40;) (type 1) (result i64) + f64.const inf (;=inf;) + i64.reinterpret/f64) + (func (;41;) (type 1) (result i64) + f64.const inf (;=inf;) + i64.reinterpret/f64) + (func (;42;) (type 1) (result i64) + f64.const -inf (;=-inf;) + i64.reinterpret/f64) + (func (;43;) (type 1) (result i64) + f64.const 0x0p+0 (;=0;) + i64.reinterpret/f64) + (func (;44;) (type 1) (result i64) + f64.const 0x0p+0 (;=0;) + i64.reinterpret/f64) + (func (;45;) (type 1) (result i64) + f64.const -0x0p+0 (;=-0;) + i64.reinterpret/f64) + (func (;46;) (type 1) (result i64) + f64.const 0x1.921fb54442d18p+2 (;=6.28319;) + i64.reinterpret/f64) + (func (;47;) (type 1) (result i64) + f64.const 0x1.p-1074 (;=4.94066e-324;) + i64.reinterpret/f64) + (func (;48;) (type 1) (result i64) + f64.const 0x1p-1022 (;=2.22507e-308;) + i64.reinterpret/f64) + (func (;49;) (type 1) (result i64) + f64.const 0x1.ffffffffffffep-1023 (;=2.22507e-308;) + i64.reinterpret/f64) + (func (;50;) (type 1) (result i64) + f64.const 0x1.fffffffffffffp+1023 (;=1.79769e+308;) + i64.reinterpret/f64) + (func (;51;) (type 1) (result i64) + f64.const 0x1p+100 (;=1.26765e+30;) + i64.reinterpret/f64) + (func (;52;) (type 1) (result i64) + f64.const 0x0p+0 (;=0;) + i64.reinterpret/f64) + (func (;53;) (type 1) (result i64) + f64.const 0x0p+0 (;=0;) + i64.reinterpret/f64) + (func (;54;) (type 1) (result i64) + f64.const -0x0p+0 (;=-0;) + i64.reinterpret/f64) + (func (;55;) (type 1) (result i64) + f64.const 0x1.921fb54442d18p+2 (;=6.28319;) + i64.reinterpret/f64) + (func (;56;) (type 1) (result i64) + f64.const 0x1.p-1074 (;=4.94066e-324;) + i64.reinterpret/f64) + (func (;57;) (type 1) (result i64) + f64.const 0x1p-1022 (;=2.22507e-308;) + i64.reinterpret/f64) + (func (;58;) (type 1) (result i64) + f64.const 0x1.ffffffffffffep-1023 (;=2.22507e-308;) + i64.reinterpret/f64) + (func (;59;) (type 1) (result i64) + f64.const 0x1.fffffffffffffp+1023 (;=1.79769e+308;) + i64.reinterpret/f64) + (func (;60;) (type 1) (result i64) + f64.const 0x1.249ad2594c37dp+332 (;=1e+100;) + i64.reinterpret/f64) + (func (;61;) (type 1) (result i64) + f64.const 0x1.000001ff19e24p+0 (;=1;) + i64.reinterpret/f64) + (func (;62;) (type 2) (result f32) + f32.const 0x1.e848p+19 (;=1e+06;)) + (func (;63;) (type 2) (result f32) + f32.const 0x1.f4p+9 (;=1000;)) + (func (;64;) (type 2) (result f32) + f32.const 0x1.f5922p+9 (;=1003.14;)) + (func (;65;) (type 2) (result f32) + f32.const 0x1.c2332cp+49 (;=9.9e+14;)) + (func (;66;) (type 2) (result f32) + f32.const 0x1.3b5ce8p+93 (;=1.22e+28;)) + (func (;67;) (type 2) (result f32) + f32.const 0x1.41e014p+27 (;=1.68755e+08;)) + (func (;68;) (type 2) (result f32) + f32.const 0x1.aa0fp+16 (;=109071;)) + (func (;69;) (type 2) (result f32) + f32.const 0x1.41ffe2p+15 (;=41215.9;)) + (func (;70;) (type 2) (result f32) + f32.const 0x1.ep+20 (;=1.96608e+06;)) + (func (;71;) (type 2) (result f32) + f32.const 0x1.57805p+44 (;=2.36052e+13;)) + (func (;72;) (type 3) (result f64) + f64.const 0x1.e848p+19 (;=1e+06;)) + (func (;73;) (type 3) (result f64) + f64.const 0x1.f4p+9 (;=1000;)) + (func (;74;) (type 3) (result f64) + f64.const 0x1.f5921fafc8bp+9 (;=1003.14;)) + (func (;75;) (type 3) (result f64) + f64.const 0x1.05c735bb7cc45p-402 (;=9.9e-122;)) + (func (;76;) (type 3) (result f64) + f64.const 0x1.3b5ce725bde9cp+93 (;=1.22e+28;)) + (func (;77;) (type 3) (result f64) + f64.const 0x1.5e01e00013332p+51 (;=3.0787e+15;)) + (func (;78;) (type 3) (result f64) + f64.const 0x1.aa0fp+16 (;=109071;)) + (func (;79;) (type 3) (result f64) + f64.const 0x1.41ffe2834b34p+15 (;=41215.9;)) + (func (;80;) (type 3) (result f64) + f64.const 0x1.ep+20 (;=1.96608e+06;)) + (func (;81;) (type 3) (result f64) + f64.const 0x1.578050f9f7p+44 (;=2.36052e+13;)) + (export \"f32.nan\" (func 0)) + (export \"f32.positive_nan\" (func 1)) + (export \"f32.negative_nan\" (func 2)) + (export \"f32.plain_nan\" (func 3)) + (export \"f32.informally_known_as_plain_snan\" (func 4)) + (export \"f32.all_ones_nan\" (func 5)) + (export \"f32.misc_nan\" (func 6)) + (export \"f32.misc_positive_nan\" (func 7)) + (export \"f32.misc_negative_nan\" (func 8)) + (export \"f32.infinity\" (func 9)) + (export \"f32.positive_infinity\" (func 10)) + (export \"f32.negative_infinity\" (func 11)) + (export \"f32.zero\" (func 12)) + (export \"f32.positive_zero\" (func 13)) + (export \"f32.negative_zero\" (func 14)) + (export \"f32.misc\" (func 15)) + (export \"f32.min_positive\" (func 16)) + (export \"f32.min_normal\" (func 17)) + (export \"f32.max_finite\" (func 18)) + (export \"f32.max_subnormal\" (func 19)) + (export \"f32.trailing_dot\" (func 20)) + (export \"f32_dec.zero\" (func 21)) + (export \"f32_dec.positive_zero\" (func 22)) + (export \"f32_dec.negative_zero\" (func 23)) + (export \"f32_dec.misc\" (func 24)) + (export \"f32_dec.min_positive\" (func 25)) + (export \"f32_dec.min_normal\" (func 26)) + (export \"f32_dec.max_subnormal\" (func 27)) + (export \"f32_dec.max_finite\" (func 28)) + (export \"f32_dec.trailing_dot\" (func 29)) + (export \"f32_dec.root_beer_float\" (func 30)) + (export \"f64.nan\" (func 31)) + (export \"f64.positive_nan\" (func 32)) + (export \"f64.negative_nan\" (func 33)) + (export \"f64.plain_nan\" (func 34)) + (export \"f64.informally_known_as_plain_snan\" (func 35)) + (export \"f64.all_ones_nan\" (func 36)) + (export \"f64.misc_nan\" (func 37)) + (export \"f64.misc_positive_nan\" (func 38)) + (export \"f64.misc_negative_nan\" (func 39)) + (export \"f64.infinity\" (func 40)) + (export \"f64.positive_infinity\" (func 41)) + (export \"f64.negative_infinity\" (func 42)) + (export \"f64.zero\" (func 43)) + (export \"f64.positive_zero\" (func 44)) + (export \"f64.negative_zero\" (func 45)) + (export \"f64.misc\" (func 46)) + (export \"f64.min_positive\" (func 47)) + (export \"f64.min_normal\" (func 48)) + (export \"f64.max_subnormal\" (func 49)) + (export \"f64.max_finite\" (func 50)) + (export \"f64.trailing_dot\" (func 51)) + (export \"f64_dec.zero\" (func 52)) + (export \"f64_dec.positive_zero\" (func 53)) + (export \"f64_dec.negative_zero\" (func 54)) + (export \"f64_dec.misc\" (func 55)) + (export \"f64_dec.min_positive\" (func 56)) + (export \"f64_dec.min_normal\" (func 57)) + (export \"f64_dec.max_subnormal\" (func 58)) + (export \"f64_dec.max_finite\" (func 59)) + (export \"f64_dec.trailing_dot\" (func 60)) + (export \"f64_dec.root_beer_float\" (func 61)) + (export \"f32-dec-sep1\" (func 62)) + (export \"f32-dec-sep2\" (func 63)) + (export \"f32-dec-sep3\" (func 64)) + (export \"f32-dec-sep4\" (func 65)) + (export \"f32-dec-sep5\" (func 66)) + (export \"f32-hex-sep1\" (func 67)) + (export \"f32-hex-sep2\" (func 68)) + (export \"f32-hex-sep3\" (func 69)) + (export \"f32-hex-sep4\" (func 70)) + (export \"f32-hex-sep5\" (func 71)) + (export \"f64-dec-sep1\" (func 72)) + (export \"f64-dec-sep2\" (func 73)) + (export \"f64-dec-sep3\" (func 74)) + (export \"f64-dec-sep4\" (func 75)) + (export \"f64-dec-sep5\" (func 76)) + (export \"f64-hex-sep1\" (func 77)) + (export \"f64-hex-sep2\" (func 78)) + (export \"f64-hex-sep3\" (func 79)) + (export \"f64-hex-sep4\" (func 80)) + (export \"f64-hex-sep5\" (func 81))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 105 +fn l105_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l105_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2143289344 as i32); +} + +// Line 106 +fn l106_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l106_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.positive_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2143289344 as i32); +} + +// Line 107 +fn l107_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l107_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.negative_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -4194304 as i32); +} + +// Line 108 +fn l108_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l108_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.plain_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2143289344 as i32); +} + +// Line 109 +fn l109_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l109_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.informally_known_as_plain_snan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2141192192 as i32); +} + +// Line 110 +fn l110_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l110_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.all_ones_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -1 as i32); +} + +// Line 111 +fn l111_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l111_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.misc_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2139169605 as i32); +} + +// Line 112 +fn l112_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l112_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.misc_positive_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2142257232 as i32); +} + +// Line 113 +fn l113_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l113_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.misc_negative_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -5587746 as i32); +} + +// Line 114 +fn l114_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l114_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.infinity") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2139095040 as i32); +} + +// Line 115 +fn l115_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l115_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.positive_infinity") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2139095040 as i32); +} + +// Line 116 +fn l116_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l116_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.negative_infinity") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -8388608 as i32); +} + +// Line 117 +fn l117_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l117_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i32); +} + +// Line 118 +fn l118_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l118_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.positive_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i32); +} + +// Line 119 +fn l119_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l119_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.negative_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -2147483648 as i32); +} + +// Line 120 +fn l120_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l120_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.misc") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1086918619 as i32); +} + +// Line 121 +fn l121_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l121_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.min_positive") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 122 +fn l122_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l122_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.min_normal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 8388608 as i32); +} + +// Line 123 +fn l123_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l123_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.max_subnormal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 8388607 as i32); +} + +// Line 124 +fn l124_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l124_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.max_finite") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2139095039 as i32); +} + +// Line 125 +fn l125_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l125_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32.trailing_dot") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1149239296 as i32); +} + +// Line 126 +fn l126_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l126_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i32); +} + +// Line 127 +fn l127_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l127_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.positive_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i32); +} + +// Line 128 +fn l128_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l128_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.negative_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -2147483648 as i32); +} + +// Line 129 +fn l129_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l129_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.misc") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1086918619 as i32); +} + +// Line 130 +fn l130_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l130_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.min_positive") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 131 +fn l131_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l131_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.min_normal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 8388608 as i32); +} + +// Line 132 +fn l132_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l132_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.max_subnormal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 8388607 as i32); +} + +// Line 133 +fn l133_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l133_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.max_finite") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2139095039 as i32); +} + +// Line 134 +fn l134_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l134_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.trailing_dot") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1343554297 as i32); +} + +// Line 135 +fn l135_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l135_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32_dec.root_beer_float") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1065353217 as i32); +} + +// Line 137 +fn l137_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l137_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9221120237041090560 as i64); +} + +// Line 138 +fn l138_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l138_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.positive_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9221120237041090560 as i64); +} + +// Line 139 +fn l139_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l139_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.negative_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -2251799813685248 as i64); +} + +// Line 140 +fn l140_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l140_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.plain_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9221120237041090560 as i64); +} + +// Line 141 +fn l141_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l141_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.informally_known_as_plain_snan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9219994337134247936 as i64); +} + +// Line 142 +fn l142_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l142_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.all_ones_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -1 as i64); +} + +// Line 143 +fn l143_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l143_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.misc_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9218888453225749180 as i64); +} + +// Line 144 +fn l144_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l144_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.misc_positive_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9219717281780008969 as i64); +} + +// Line 145 +fn l145_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l145_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.misc_negative_nan") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -3751748707474619 as i64); +} + +// Line 146 +fn l146_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l146_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.infinity") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9218868437227405312 as i64); +} + +// Line 147 +fn l147_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l147_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.positive_infinity") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9218868437227405312 as i64); +} + +// Line 148 +fn l148_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l148_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.negative_infinity") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -4503599627370496 as i64); +} + +// Line 149 +fn l149_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l149_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i64); +} + +// Line 150 +fn l150_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l150_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.positive_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i64); +} + +// Line 151 +fn l151_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l151_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.negative_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -9223372036854775808 as i64); +} + +// Line 152 +fn l152_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l152_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.misc") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4618760256179416344 as i64); +} + +// Line 153 +fn l153_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l153_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.min_positive") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i64); +} + +// Line 154 +fn l154_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l154_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.min_normal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4503599627370496 as i64); +} + +// Line 155 +fn l155_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l155_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.max_subnormal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4503599627370495 as i64); +} + +// Line 156 +fn l156_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l156_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.max_finite") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9218868437227405311 as i64); +} + +// Line 157 +fn l157_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l157_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64.trailing_dot") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 5057542381537067008 as i64); +} + +// Line 158 +fn l158_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l158_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i64); +} + +// Line 159 +fn l159_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l159_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.positive_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i64); +} + +// Line 160 +fn l160_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l160_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.negative_zero") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, -9223372036854775808 as i64); +} + +// Line 161 +fn l161_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l161_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.misc") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4618760256179416344 as i64); +} + +// Line 162 +fn l162_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l162_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.min_positive") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i64); +} + +// Line 163 +fn l163_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l163_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.min_normal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4503599627370496 as i64); +} + +// Line 164 +fn l164_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l164_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.max_subnormal") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4503599627370495 as i64); +} + +// Line 165 +fn l165_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l165_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.max_finite") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9218868437227405311 as i64); +} + +// Line 166 +fn l166_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l166_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.trailing_dot") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 6103021453049119613 as i64); +} + +// Line 167 +fn l167_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l167_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64_dec.root_beer_float") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4607182419335945764 as i64); +} + +// Line 169 +fn l169_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l169_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-dec-sep1") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1000000.0 as f32); +} + +// Line 170 +fn l170_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l170_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-dec-sep2") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1000.0 as f32); +} + +// Line 171 +fn l171_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l171_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-dec-sep3") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1003.1416 as f32); +} + +// Line 172 +fn l172_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l172_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-dec-sep4") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 990000000000000.0 as f32); +} + +// Line 173 +fn l173_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l173_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-dec-sep5") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 12200012000000000000000000000.0 as f32); +} + +// Line 174 +fn l174_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l174_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-hex-sep1") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 168755360.0 as f32); +} + +// Line 175 +fn l175_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l175_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-hex-sep2") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 109071.0 as f32); +} + +// Line 176 +fn l176_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l176_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-hex-sep3") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 41215.94 as f32); +} + +// Line 177 +fn l177_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l177_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-hex-sep4") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1966080.0 as f32); +} + +// Line 178 +fn l178_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l178_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f32-hex-sep5") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 23605224000000.0 as f32); +} + +// Line 180 +fn l180_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l180_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-dec-sep1") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1000000.0 as f64); +} + +// Line 181 +fn l181_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l181_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-dec-sep2") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1000.0 as f64); +} + +// Line 182 +fn l182_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l182_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-dec-sep3") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1003.141592 as f64); +} + +// Line 183 +fn l183_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l183_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-dec-sep4") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099 as f64); +} + +// Line 184 +fn l184_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l184_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-dec-sep5") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 12200011354000000000000000000.0 as f64); +} + +// Line 185 +fn l185_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l185_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-hex-sep1") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3078696982321561.0 as f64); +} + +// Line 186 +fn l186_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l186_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-hex-sep2") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 109071.0 as f64); +} + +// Line 187 +fn l187_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l187_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-hex-sep3") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 41215.94240794191 as f64); +} + +// Line 188 +fn l188_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l188_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-hex-sep4") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1966080.0 as f64); +} + +// Line 189 +fn l189_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l189_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("f64-hex-sep5") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 23605225168752.0 as f64); +} + +// Line 192 + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l105_assert_return_invoke(&result_object, &vm_context); + l106_assert_return_invoke(&result_object, &vm_context); + l107_assert_return_invoke(&result_object, &vm_context); + l108_assert_return_invoke(&result_object, &vm_context); + l109_assert_return_invoke(&result_object, &vm_context); + l110_assert_return_invoke(&result_object, &vm_context); + l111_assert_return_invoke(&result_object, &vm_context); + l112_assert_return_invoke(&result_object, &vm_context); + l113_assert_return_invoke(&result_object, &vm_context); + l114_assert_return_invoke(&result_object, &vm_context); + l115_assert_return_invoke(&result_object, &vm_context); + l116_assert_return_invoke(&result_object, &vm_context); + l117_assert_return_invoke(&result_object, &vm_context); + l118_assert_return_invoke(&result_object, &vm_context); + l119_assert_return_invoke(&result_object, &vm_context); + l120_assert_return_invoke(&result_object, &vm_context); + l121_assert_return_invoke(&result_object, &vm_context); + l122_assert_return_invoke(&result_object, &vm_context); + l123_assert_return_invoke(&result_object, &vm_context); + l124_assert_return_invoke(&result_object, &vm_context); + l125_assert_return_invoke(&result_object, &vm_context); + l126_assert_return_invoke(&result_object, &vm_context); + l127_assert_return_invoke(&result_object, &vm_context); + l128_assert_return_invoke(&result_object, &vm_context); + l129_assert_return_invoke(&result_object, &vm_context); + l130_assert_return_invoke(&result_object, &vm_context); + l131_assert_return_invoke(&result_object, &vm_context); + l132_assert_return_invoke(&result_object, &vm_context); + l133_assert_return_invoke(&result_object, &vm_context); + l134_assert_return_invoke(&result_object, &vm_context); + l135_assert_return_invoke(&result_object, &vm_context); + l137_assert_return_invoke(&result_object, &vm_context); + l138_assert_return_invoke(&result_object, &vm_context); + l139_assert_return_invoke(&result_object, &vm_context); + l140_assert_return_invoke(&result_object, &vm_context); + l141_assert_return_invoke(&result_object, &vm_context); + l142_assert_return_invoke(&result_object, &vm_context); + l143_assert_return_invoke(&result_object, &vm_context); + l144_assert_return_invoke(&result_object, &vm_context); + l145_assert_return_invoke(&result_object, &vm_context); + l146_assert_return_invoke(&result_object, &vm_context); + l147_assert_return_invoke(&result_object, &vm_context); + l148_assert_return_invoke(&result_object, &vm_context); + l149_assert_return_invoke(&result_object, &vm_context); + l150_assert_return_invoke(&result_object, &vm_context); + l151_assert_return_invoke(&result_object, &vm_context); + l152_assert_return_invoke(&result_object, &vm_context); + l153_assert_return_invoke(&result_object, &vm_context); + l154_assert_return_invoke(&result_object, &vm_context); + l155_assert_return_invoke(&result_object, &vm_context); + l156_assert_return_invoke(&result_object, &vm_context); + l157_assert_return_invoke(&result_object, &vm_context); + l158_assert_return_invoke(&result_object, &vm_context); + l159_assert_return_invoke(&result_object, &vm_context); + l160_assert_return_invoke(&result_object, &vm_context); + l161_assert_return_invoke(&result_object, &vm_context); + l162_assert_return_invoke(&result_object, &vm_context); + l163_assert_return_invoke(&result_object, &vm_context); + l164_assert_return_invoke(&result_object, &vm_context); + l165_assert_return_invoke(&result_object, &vm_context); + l166_assert_return_invoke(&result_object, &vm_context); + l167_assert_return_invoke(&result_object, &vm_context); + l169_assert_return_invoke(&result_object, &vm_context); + l170_assert_return_invoke(&result_object, &vm_context); + l171_assert_return_invoke(&result_object, &vm_context); + l172_assert_return_invoke(&result_object, &vm_context); + l173_assert_return_invoke(&result_object, &vm_context); + l174_assert_return_invoke(&result_object, &vm_context); + l175_assert_return_invoke(&result_object, &vm_context); + l176_assert_return_invoke(&result_object, &vm_context); + l177_assert_return_invoke(&result_object, &vm_context); + l178_assert_return_invoke(&result_object, &vm_context); + l180_assert_return_invoke(&result_object, &vm_context); + l181_assert_return_invoke(&result_object, &vm_context); + l182_assert_return_invoke(&result_object, &vm_context); + l183_assert_return_invoke(&result_object, &vm_context); + l184_assert_return_invoke(&result_object, &vm_context); + l185_assert_return_invoke(&result_object, &vm_context); + l186_assert_return_invoke(&result_object, &vm_context); + l187_assert_return_invoke(&result_object, &vm_context); + l188_assert_return_invoke(&result_object, &vm_context); + l189_assert_return_invoke(&result_object, &vm_context); +} +fn create_module_2() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result f64))) + (func (;0;) (type 0) (result f64) + f64.const 0x1.ffffffa2p+31 (;=4.29497e+09;)) + (export \"4294967249\" (func 0))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 201 +fn l201_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l201_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("4294967249") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4294967249.0 as f64); +} + +// Line 204 +#[test] +fn l204_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 208 +#[test] +fn l208_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 43, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 212 +#[test] +fn l212_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 45, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 216 +#[test] +fn l216_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 57, 57, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 220 +#[test] +fn l220_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 95, 95, 48, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 224 +#[test] +fn l224_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 95, 49, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 228 +#[test] +fn l228_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 232 +#[test] +fn l232_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 95, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 236 +#[test] +fn l236_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 95, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 240 +#[test] +fn l240_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 95, 49, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 244 +#[test] +fn l244_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 101, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 248 +#[test] +fn l248_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 95, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 252 +#[test] +fn l252_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 101, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 256 +#[test] +fn l256_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 95, 49, 46, 48, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 260 +#[test] +fn l260_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 264 +#[test] +fn l264_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 95, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 268 +#[test] +fn l268_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 272 +#[test] +fn l272_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 43, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 276 +#[test] +fn l276_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 95, 43, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 280 +#[test] +fn l280_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 95, 48, 120, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 284 +#[test] +fn l284_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 95, 120, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 288 +#[test] +fn l288_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 292 +#[test] +fn l292_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 48, 48, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 296 +#[test] +fn l296_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 102, 102, 95, 95, 102, 102, 102, 102, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 300 +#[test] +fn l300_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 304 +#[test] +fn l304_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 308 +#[test] +fn l308_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 95, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 312 +#[test] +fn l312_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 95, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 316 +#[test] +fn l316_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 320 +#[test] +fn l320_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 112, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 324 +#[test] +fn l324_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 95, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 328 +#[test] +fn l328_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 112, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 332 +#[test] +fn l332_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 46, 48, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 336 +#[test] +fn l336_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 340 +#[test] +fn l340_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 95, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 344 +#[test] +fn l344_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 348 +#[test] +fn l348_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 43, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 352 +#[test] +fn l352_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 51, 50, 32, 40, 102, 51, 50, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 95, 43, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 357 +#[test] +fn l357_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 361 +#[test] +fn l361_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 43, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 365 +#[test] +fn l365_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 45, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 369 +#[test] +fn l369_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 57, 57, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 373 +#[test] +fn l373_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 95, 95, 48, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 377 +#[test] +fn l377_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 95, 49, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 381 +#[test] +fn l381_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 385 +#[test] +fn l385_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 95, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 389 +#[test] +fn l389_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 95, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 393 +#[test] +fn l393_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 95, 49, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 397 +#[test] +fn l397_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 101, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 401 +#[test] +fn l401_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 95, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 405 +#[test] +fn l405_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 101, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 409 +#[test] +fn l409_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 95, 49, 46, 48, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 413 +#[test] +fn l413_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 417 +#[test] +fn l417_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 95, 101, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 421 +#[test] +fn l421_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 425 +#[test] +fn l425_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 43, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 429 +#[test] +fn l429_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 49, 46, 48, 101, 95, 43, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 433 +#[test] +fn l433_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 95, 48, 120, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 437 +#[test] +fn l437_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 95, 120, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 441 +#[test] +fn l441_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 48, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 445 +#[test] +fn l445_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 48, 48, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 449 +#[test] +fn l449_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 102, 102, 95, 95, 102, 102, 102, 102, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 453 +#[test] +fn l453_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 457 +#[test] +fn l457_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 461 +#[test] +fn l461_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 95, 46, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 465 +#[test] +fn l465_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 95, 48, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 469 +#[test] +fn l469_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 473 +#[test] +fn l473_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 112, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 477 +#[test] +fn l477_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 95, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 481 +#[test] +fn l481_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 112, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 485 +#[test] +fn l485_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 95, 49, 46, 48, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 489 +#[test] +fn l489_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 49, 95, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 493 +#[test] +fn l493_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 95, 112, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 497 +#[test] +fn l497_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 501 +#[test] +fn l501_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 43, 95, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +// Line 505 +#[test] +fn l505_assert_malformed() { + let wasm_binary = [40, 103, 108, 111, 98, 97, 108, 32, 102, 54, 52, 32, 40, 102, 54, 52, 46, 99, 111, 110, 115, 116, 32, 48, 120, 49, 46, 48, 112, 95, 43, 49, 41, 41]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is malformed"); +} + +#[test] +fn test_module_2() { + let result_object = create_module_2(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l201_assert_return_invoke(&result_object, &vm_context); +} diff --git a/src/spectests/mod.rs b/src/spectests/mod.rs index e4f2d4127..e2edc09bd 100644 --- a/src/spectests/mod.rs +++ b/src/spectests/mod.rs @@ -14,6 +14,7 @@ mod call; mod call_indirect; mod const_; mod data; +mod endianness; mod exports; mod f32_; mod f32_bitwise; @@ -21,10 +22,15 @@ mod f32_cmp; mod f64_; mod f64_bitwise; mod f64_cmp; +mod float_literals; mod func_ptrs; mod i32_; mod i64_; mod labels; mod memory; +mod return_; +mod select; mod set_local; +mod switch; +mod tee_local; mod types; diff --git a/src/spectests/put/elem.wast b/src/spectests/put/elem.wast new file mode 100644 index 000000000..3c204c073 --- /dev/null +++ b/src/spectests/put/elem.wast @@ -0,0 +1,381 @@ +;; Test the element section + +;; Syntax +(module + (table $t 10 anyfunc) + (func $f) + (elem (i32.const 0)) + (elem (i32.const 0) $f $f) + (elem (offset (i32.const 0))) + (elem (offset (i32.const 0)) $f $f) + (elem 0 (i32.const 0)) + (elem 0x0 (i32.const 0) $f $f) + (elem 0x000 (offset (i32.const 0))) + (elem 0 (offset (i32.const 0)) $f $f) + (elem $t (i32.const 0)) + (elem $t (i32.const 0) $f $f) + (elem $t (offset (i32.const 0))) + (elem $t (offset (i32.const 0)) $f $f) +) + +;; Basic use + +(module + (table 10 anyfunc) + (func $f) + (elem (i32.const 0) $f) +) +(module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 0) $f) +) + +(module + (table 10 anyfunc) + (func $f) + (elem (i32.const 0) $f) + (elem (i32.const 3) $f) + (elem (i32.const 7) $f) + (elem (i32.const 5) $f) + (elem (i32.const 3) $f) +) +(module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 9) $f) + (elem (i32.const 3) $f) + (elem (i32.const 7) $f) + (elem (i32.const 3) $f) + (elem (i32.const 5) $f) +) + +(module + (global (import "spectest" "global_i32") i32) + (table 1000 anyfunc) + (func $f) + (elem (get_global 0) $f) +) + +(module + (global $g (import "spectest" "global_i32") i32) + (table 1000 anyfunc) + (func $f) + (elem (get_global $g) $f) +) + +(module + (type $out-i32 (func (result i32))) + (table 10 anyfunc) + (elem (i32.const 7) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-7") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 7)) + ) + (func (export "call-9") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) +(assert_return (invoke "call-7") (i32.const 65)) +(assert_return (invoke "call-9") (i32.const 66)) + +;; Corner cases + +(module + (table 10 anyfunc) + (func $f) + (elem (i32.const 9) $f) +) +(module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 9) $f) +) + +(module + (table 0 anyfunc) + (elem (i32.const 0)) +) +(module + (import "spectest" "table" (table 0 anyfunc)) + (elem (i32.const 0)) +) + +(module + (table 0 0 anyfunc) + (elem (i32.const 0)) +) + +(module + (table 20 anyfunc) + (elem (i32.const 20)) +) + +(module + (import "spectest" "table" (table 0 anyfunc)) + (func $f) + (elem (i32.const 0) $f) +) + +(module + (import "spectest" "table" (table 0 100 anyfunc)) + (func $f) + (elem (i32.const 0) $f) +) + +(module + (import "spectest" "table" (table 0 anyfunc)) + (func $f) + (elem (i32.const 1) $f) +) + +(module + (import "spectest" "table" (table 0 30 anyfunc)) + (func $f) + (elem (i32.const 1) $f) +) + +;; Invalid bounds for elements + +(assert_unlinkable + (module + (table 0 anyfunc) + (func $f) + (elem (i32.const 0) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 0 0 anyfunc) + (func $f) + (elem (i32.const 0) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 0 1 anyfunc) + (func $f) + (elem (i32.const 0) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 0 anyfunc) + (elem (i32.const 1)) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 anyfunc) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 20 anyfunc) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const 10) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 anyfunc) + (func $f) + (elem (i32.const -1) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const -1) $f) + ) + "elements segment does not fit" +) + +(assert_unlinkable + (module + (table 10 anyfunc) + (func $f) + (elem (i32.const -10) $f) + ) + "elements segment does not fit" +) +(assert_unlinkable + (module + (import "spectest" "table" (table 10 anyfunc)) + (func $f) + (elem (i32.const -10) $f) + ) + "elements segment does not fit" +) + +;; Element without table + +(assert_invalid + (module + (func $f) + (elem (i32.const 0) $f) + ) + "unknown table 0" +) + +;; Invalid offsets + +(assert_invalid + (module + (table 1 anyfunc) + (elem (i64.const 0)) + ) + "type mismatch" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (i32.ctz (i32.const 0))) + ) + "constant expression required" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (nop)) + ) + "constant expression required" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (offset (nop) (i32.const 0))) + ) + "constant expression required" +) + +(assert_invalid + (module + (table 1 anyfunc) + (elem (offset (i32.const 0) (nop))) + ) + "constant expression required" +) + +;; Use of internal globals in constant expressions is not allowed in MVP. +;; (assert_invalid +;; (module (memory 1) (data (get_global $g)) (global $g (mut i32) (i32.const 0))) +;; "constant expression required" +;; ) + +;; Two elements target the same slot + +(module + (type $out-i32 (func (result i32))) + (table 10 anyfunc) + (elem (i32.const 9) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-overwritten") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) +(assert_return (invoke "call-overwritten") (i32.const 66)) + +(module + (type $out-i32 (func (result i32))) + (import "spectest" "table" (table 10 anyfunc)) + (elem (i32.const 9) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-overwritten-element") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) +(assert_return (invoke "call-overwritten-element") (i32.const 66)) + +;; Element sections across multiple modules change the same table + +(module $module1 + (type $out-i32 (func (result i32))) + (table (export "shared-table") 10 anyfunc) + (elem (i32.const 8) $const-i32-a) + (elem (i32.const 9) $const-i32-b) + (func $const-i32-a (type $out-i32) (i32.const 65)) + (func $const-i32-b (type $out-i32) (i32.const 66)) + (func (export "call-7") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 7)) + ) + (func (export "call-8") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 8)) + ) + (func (export "call-9") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 9)) + ) +) + +(register "module1" $module1) + +(assert_trap (invoke $module1 "call-7") "uninitialized element 7") +(assert_return (invoke $module1 "call-8") (i32.const 65)) +(assert_return (invoke $module1 "call-9") (i32.const 66)) + +(module $module2 + (type $out-i32 (func (result i32))) + (import "module1" "shared-table" (table 10 anyfunc)) + (elem (i32.const 7) $const-i32-c) + (elem (i32.const 8) $const-i32-d) + (func $const-i32-c (type $out-i32) (i32.const 67)) + (func $const-i32-d (type $out-i32) (i32.const 68)) +) + +(assert_return (invoke $module1 "call-7") (i32.const 67)) +(assert_return (invoke $module1 "call-8") (i32.const 68)) +(assert_return (invoke $module1 "call-9") (i32.const 66)) + +(module $module3 + (type $out-i32 (func (result i32))) + (import "module1" "shared-table" (table 10 anyfunc)) + (elem (i32.const 8) $const-i32-e) + (elem (i32.const 9) $const-i32-f) + (func $const-i32-e (type $out-i32) (i32.const 69)) + (func $const-i32-f (type $out-i32) (i32.const 70)) +) + +(assert_return (invoke $module1 "call-7") (i32.const 67)) +(assert_return (invoke $module1 "call-8") (i32.const 69)) +(assert_return (invoke $module1 "call-9") (i32.const 70)) diff --git a/src/spectests/put/if_.wast b/src/spectests/put/if_.wast new file mode 100644 index 000000000..1c2f90225 --- /dev/null +++ b/src/spectests/put/if_.wast @@ -0,0 +1,742 @@ +;; Test `if` operator + +(module + ;; Auxiliary definition + (memory 1) + + (func $dummy) + + (func (export "empty") (param i32) + (if (get_local 0) (then)) + (if (get_local 0) (then) (else)) + (if $l (get_local 0) (then)) + (if $l (get_local 0) (then) (else)) + ) + + (func (export "singular") (param i32) (result i32) + (if (get_local 0) (then (nop))) + (if (get_local 0) (then (nop)) (else (nop))) + (if (result i32) (get_local 0) (then (i32.const 7)) (else (i32.const 8))) + ) + + (func (export "multi") (param i32) (result i32) + (if (get_local 0) (then (call $dummy) (call $dummy) (call $dummy))) + (if (get_local 0) (then) (else (call $dummy) (call $dummy) (call $dummy))) + (if (result i32) (get_local 0) + (then (call $dummy) (call $dummy) (i32.const 8)) + (else (call $dummy) (call $dummy) (i32.const 9)) + ) + ) + + (func (export "nested") (param i32 i32) (result i32) + (if (result i32) (get_local 0) + (then + (if (get_local 1) (then (call $dummy) (block) (nop))) + (if (get_local 1) (then) (else (call $dummy) (block) (nop))) + (if (result i32) (get_local 1) + (then (call $dummy) (i32.const 9)) + (else (call $dummy) (i32.const 10)) + ) + ) + (else + (if (get_local 1) (then (call $dummy) (block) (nop))) + (if (get_local 1) (then) (else (call $dummy) (block) (nop))) + (if (result i32) (get_local 1) + (then (call $dummy) (i32.const 10)) + (else (call $dummy) (i32.const 11)) + ) + ) + ) + ) + + (func (export "as-select-first") (param i32) (result i32) + (select + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 2) (i32.const 3) + ) + ) + (func (export "as-select-mid") (param i32) (result i32) + (select + (i32.const 2) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 3) + ) + ) + (func (export "as-select-last") (param i32) (result i32) + (select + (i32.const 2) (i32.const 3) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + ) + ) + + (func (export "as-loop-first") (param i32) (result i32) + (loop (result i32) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (call $dummy) (call $dummy) + ) + ) + (func (export "as-loop-mid") (param i32) (result i32) + (loop (result i32) + (call $dummy) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (call $dummy) + ) + ) + (func (export "as-loop-last") (param i32) (result i32) + (loop (result i32) + (call $dummy) (call $dummy) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + ) + ) + + (func (export "as-if-condition") (param i32) (result i32) + (if (result i32) + (if (result i32) (get_local 0) + (then (i32.const 1)) (else (i32.const 0)) + ) + (then (call $dummy) (i32.const 2)) + (else (call $dummy) (i32.const 3)) + ) + ) + + (func (export "as-br_if-first") (param i32) (result i32) + (block (result i32) + (br_if 0 + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 2) + ) + (return (i32.const 3)) + ) + ) + (func (export "as-br_if-last") (param i32) (result i32) + (block (result i32) + (br_if 0 + (i32.const 2) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + ) + (return (i32.const 3)) + ) + ) + + (func (export "as-br_table-first") (param i32) (result i32) + (block (result i32) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 2) + (br_table 0 0) + ) + ) + (func (export "as-br_table-last") (param i32) (result i32) + (block (result i32) + (i32.const 2) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (br_table 0 0) + ) + ) + + (func $func (param i32 i32) (result i32) (get_local 0)) + (type $check (func (param i32 i32) (result i32))) + (table anyfunc (elem $func)) + (func (export "as-call_indirect-first") (param i32) (result i32) + (block (result i32) + (call_indirect (type $check) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 2) (i32.const 0) + ) + ) + ) + (func (export "as-call_indirect-mid") (param i32) (result i32) + (block (result i32) + (call_indirect (type $check) + (i32.const 2) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 0) + ) + ) + ) + (func (export "as-call_indirect-last") (param i32) (result i32) + (block (result i32) + (call_indirect (type $check) + (i32.const 2) (i32.const 0) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + ) + ) + ) + + (func (export "as-store-first") (param i32) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.const 2) + (i32.store) + ) + (func (export "as-store-last") (param i32) + (i32.const 2) + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 1)) + (else (call $dummy) (i32.const 0)) + ) + (i32.store) + ) + + (func (export "as-memory.grow-value") (param i32) (result i32) + (memory.grow + (if (result i32) (get_local 0) + (then (i32.const 1)) + (else (i32.const 0)) + ) + ) + ) + + (func $f (param i32) (result i32) (get_local 0)) + + (func (export "as-call-value") (param i32) (result i32) + (call $f + (if (result i32) (get_local 0) + (then (i32.const 1)) + (else (i32.const 0)) + ) + ) + ) + (func (export "as-return-value") (param i32) (result i32) + (if (result i32) (get_local 0) + (then (i32.const 1)) + (else (i32.const 0))) + (return) + ) + (func (export "as-drop-operand") (param i32) + (drop + (if (result i32) (get_local 0) + (then (i32.const 1)) + (else (i32.const 0)) + ) + ) + ) + (func (export "as-br-value") (param i32) (result i32) + (block (result i32) + (br 0 + (if (result i32) (get_local 0) + (then (i32.const 1)) + (else (i32.const 0)) + ) + ) + ) + ) + (func (export "as-set_local-value") (param i32) (result i32) + (local i32) + (set_local 0 + (if (result i32) (get_local 0) + (then (i32.const 1)) + (else (i32.const 0)) + ) + ) + (get_local 0) + ) + (func (export "as-load-operand") (param i32) (result i32) + (i32.load + (if (result i32) (get_local 0) + (then (i32.const 11)) + (else (i32.const 10)) + ) + ) + ) + + (func (export "as-unary-operand") (param i32) (result i32) + (i32.ctz + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 13)) + (else (call $dummy) (i32.const -13)) + ) + ) + ) + (func (export "as-binary-operand") (param i32 i32) (result i32) + (i32.mul + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 3)) + (else (call $dummy) (i32.const -3)) + ) + (if (result i32) (get_local 1) + (then (call $dummy) (i32.const 4)) + (else (call $dummy) (i32.const -5)) + ) + ) + ) + (func (export "as-test-operand") (param i32) (result i32) + (i32.eqz + (if (result i32) (get_local 0) + (then (call $dummy) (i32.const 13)) + (else (call $dummy) (i32.const 0)) + ) + ) + ) + (func (export "as-compare-operand") (param i32 i32) (result i32) + (f32.gt + (if (result f32) (get_local 0) + (then (call $dummy) (f32.const 3)) + (else (call $dummy) (f32.const -3)) + ) + (if (result f32) (get_local 1) + (then (call $dummy) (f32.const 4)) + (else (call $dummy) (f32.const -4)) + ) + ) + ) + + (func (export "break-bare") (result i32) + (if (i32.const 1) (then (br 0) (unreachable))) + (if (i32.const 1) (then (br 0) (unreachable)) (else (unreachable))) + (if (i32.const 0) (then (unreachable)) (else (br 0) (unreachable))) + (if (i32.const 1) (then (br_if 0 (i32.const 1)) (unreachable))) + (if (i32.const 1) (then (br_if 0 (i32.const 1)) (unreachable)) (else (unreachable))) + (if (i32.const 0) (then (unreachable)) (else (br_if 0 (i32.const 1)) (unreachable))) + (if (i32.const 1) (then (br_table 0 (i32.const 0)) (unreachable))) + (if (i32.const 1) (then (br_table 0 (i32.const 0)) (unreachable)) (else (unreachable))) + (if (i32.const 0) (then (unreachable)) (else (br_table 0 (i32.const 0)) (unreachable))) + (i32.const 19) + ) + + (func (export "break-value") (param i32) (result i32) + (if (result i32) (get_local 0) + (then (br 0 (i32.const 18)) (i32.const 19)) + (else (br 0 (i32.const 21)) (i32.const 20)) + ) + ) + + (func (export "effects") (param i32) (result i32) + (local i32) + (if + (block (result i32) (set_local 1 (i32.const 1)) (get_local 0)) + (then + (set_local 1 (i32.mul (get_local 1) (i32.const 3))) + (set_local 1 (i32.sub (get_local 1) (i32.const 5))) + (set_local 1 (i32.mul (get_local 1) (i32.const 7))) + (br 0) + (set_local 1 (i32.mul (get_local 1) (i32.const 100))) + ) + (else + (set_local 1 (i32.mul (get_local 1) (i32.const 5))) + (set_local 1 (i32.sub (get_local 1) (i32.const 7))) + (set_local 1 (i32.mul (get_local 1) (i32.const 3))) + (br 0) + (set_local 1 (i32.mul (get_local 1) (i32.const 1000))) + ) + ) + (get_local 1) + ) +) + +(assert_return (invoke "empty" (i32.const 0))) +(assert_return (invoke "empty" (i32.const 1))) +(assert_return (invoke "empty" (i32.const 100))) +(assert_return (invoke "empty" (i32.const -2))) + +(assert_return (invoke "singular" (i32.const 0)) (i32.const 8)) +(assert_return (invoke "singular" (i32.const 1)) (i32.const 7)) +(assert_return (invoke "singular" (i32.const 10)) (i32.const 7)) +(assert_return (invoke "singular" (i32.const -10)) (i32.const 7)) + +(assert_return (invoke "multi" (i32.const 0)) (i32.const 9)) +(assert_return (invoke "multi" (i32.const 1)) (i32.const 8)) +(assert_return (invoke "multi" (i32.const 13)) (i32.const 8)) +(assert_return (invoke "multi" (i32.const -5)) (i32.const 8)) + +(assert_return (invoke "nested" (i32.const 0) (i32.const 0)) (i32.const 11)) +(assert_return (invoke "nested" (i32.const 1) (i32.const 0)) (i32.const 10)) +(assert_return (invoke "nested" (i32.const 0) (i32.const 1)) (i32.const 10)) +(assert_return (invoke "nested" (i32.const 3) (i32.const 2)) (i32.const 9)) +(assert_return (invoke "nested" (i32.const 0) (i32.const -100)) (i32.const 10)) +(assert_return (invoke "nested" (i32.const 10) (i32.const 10)) (i32.const 9)) +(assert_return (invoke "nested" (i32.const 0) (i32.const -1)) (i32.const 10)) +(assert_return (invoke "nested" (i32.const -111) (i32.const -2)) (i32.const 9)) + +(assert_return (invoke "as-select-first" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-select-first" (i32.const 1)) (i32.const 1)) +(assert_return (invoke "as-select-mid" (i32.const 0)) (i32.const 2)) +(assert_return (invoke "as-select-mid" (i32.const 1)) (i32.const 2)) +(assert_return (invoke "as-select-last" (i32.const 0)) (i32.const 3)) +(assert_return (invoke "as-select-last" (i32.const 1)) (i32.const 2)) + +(assert_return (invoke "as-loop-first" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-loop-first" (i32.const 1)) (i32.const 1)) +(assert_return (invoke "as-loop-mid" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-loop-mid" (i32.const 1)) (i32.const 1)) +(assert_return (invoke "as-loop-last" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-loop-last" (i32.const 1)) (i32.const 1)) + +(assert_return (invoke "as-if-condition" (i32.const 0)) (i32.const 3)) +(assert_return (invoke "as-if-condition" (i32.const 1)) (i32.const 2)) + +(assert_return (invoke "as-br_if-first" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-br_if-first" (i32.const 1)) (i32.const 1)) +(assert_return (invoke "as-br_if-last" (i32.const 0)) (i32.const 3)) +(assert_return (invoke "as-br_if-last" (i32.const 1)) (i32.const 2)) + +(assert_return (invoke "as-br_table-first" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-br_table-first" (i32.const 1)) (i32.const 1)) +(assert_return (invoke "as-br_table-last" (i32.const 0)) (i32.const 2)) +(assert_return (invoke "as-br_table-last" (i32.const 1)) (i32.const 2)) + +(assert_return (invoke "as-call_indirect-first" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-call_indirect-first" (i32.const 1)) (i32.const 1)) +(assert_return (invoke "as-call_indirect-mid" (i32.const 0)) (i32.const 2)) +(assert_return (invoke "as-call_indirect-mid" (i32.const 1)) (i32.const 2)) +(assert_return (invoke "as-call_indirect-last" (i32.const 0)) (i32.const 2)) +(assert_trap (invoke "as-call_indirect-last" (i32.const 1)) "undefined element") + +(assert_return (invoke "as-store-first" (i32.const 0))) +(assert_return (invoke "as-store-first" (i32.const 1))) +(assert_return (invoke "as-store-last" (i32.const 0))) +(assert_return (invoke "as-store-last" (i32.const 1))) + +(assert_return (invoke "as-memory.grow-value" (i32.const 0)) (i32.const 1)) +(assert_return (invoke "as-memory.grow-value" (i32.const 1)) (i32.const 1)) + +(assert_return (invoke "as-call-value" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-call-value" (i32.const 1)) (i32.const 1)) + +(assert_return (invoke "as-return-value" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-return-value" (i32.const 1)) (i32.const 1)) + +(assert_return (invoke "as-drop-operand" (i32.const 0))) +(assert_return (invoke "as-drop-operand" (i32.const 1))) + +(assert_return (invoke "as-br-value" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-br-value" (i32.const 1)) (i32.const 1)) + +(assert_return (invoke "as-set_local-value" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-set_local-value" (i32.const 1)) (i32.const 1)) + +(assert_return (invoke "as-load-operand" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-load-operand" (i32.const 1)) (i32.const 0)) + +(assert_return (invoke "as-unary-operand" (i32.const 0)) (i32.const 0)) +(assert_return (invoke "as-unary-operand" (i32.const 1)) (i32.const 0)) +(assert_return (invoke "as-unary-operand" (i32.const -1)) (i32.const 0)) + +(assert_return (invoke "as-binary-operand" (i32.const 0) (i32.const 0)) (i32.const 15)) +(assert_return (invoke "as-binary-operand" (i32.const 0) (i32.const 1)) (i32.const -12)) +(assert_return (invoke "as-binary-operand" (i32.const 1) (i32.const 0)) (i32.const -15)) +(assert_return (invoke "as-binary-operand" (i32.const 1) (i32.const 1)) (i32.const 12)) + +(assert_return (invoke "as-test-operand" (i32.const 0)) (i32.const 1)) +(assert_return (invoke "as-test-operand" (i32.const 1)) (i32.const 0)) + +(assert_return (invoke "as-compare-operand" (i32.const 0) (i32.const 0)) (i32.const 1)) +(assert_return (invoke "as-compare-operand" (i32.const 0) (i32.const 1)) (i32.const 0)) +(assert_return (invoke "as-compare-operand" (i32.const 1) (i32.const 0)) (i32.const 1)) +(assert_return (invoke "as-compare-operand" (i32.const 1) (i32.const 1)) (i32.const 0)) + +(assert_return (invoke "break-bare") (i32.const 19)) +(assert_return (invoke "break-value" (i32.const 1)) (i32.const 18)) +(assert_return (invoke "break-value" (i32.const 0)) (i32.const 21)) + +(assert_return (invoke "effects" (i32.const 1)) (i32.const -14)) +(assert_return (invoke "effects" (i32.const 0)) (i32.const -6)) + +(assert_invalid + (module (func $type-empty-i32 (result i32) (if (i32.const 0) (then)))) + "type mismatch" +) +(assert_invalid + (module (func $type-empty-i64 (result i64) (if (i32.const 0) (then)))) + "type mismatch" +) +(assert_invalid + (module (func $type-empty-f32 (result f32) (if (i32.const 0) (then)))) + "type mismatch" +) +(assert_invalid + (module (func $type-empty-f64 (result f64) (if (i32.const 0) (then)))) + "type mismatch" +) + +(assert_invalid + (module (func $type-empty-i32 (result i32) (if (i32.const 0) (then) (else)))) + "type mismatch" +) +(assert_invalid + (module (func $type-empty-i64 (result i64) (if (i32.const 0) (then) (else)))) + "type mismatch" +) +(assert_invalid + (module (func $type-empty-f32 (result f32) (if (i32.const 0) (then) (else)))) + "type mismatch" +) +(assert_invalid + (module (func $type-empty-f64 (result f64) (if (i32.const 0) (then) (else)))) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-value-num-vs-void + (if (i32.const 1) (then (i32.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-then-value-num-vs-void + (if (i32.const 1) (then (i32.const 1)) (else)) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-value-num-vs-void + (if (i32.const 1) (then) (else (i32.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-both-value-num-vs-void + (if (i32.const 1) (then (i32.const 1)) (else (i32.const 1))) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-value-empty-vs-num (result i32) + (if (result i32) (i32.const 1) (then) (else (i32.const 0))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-then-value-empty-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i32.const 0)) (else)) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-both-value-empty-vs-num (result i32) + (if (result i32) (i32.const 1) (then) (else)) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-no-else-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i32.const 1))) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-value-void-vs-num (result i32) + (if (result i32) (i32.const 1) (then (nop)) (else (i32.const 0))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-then-value-void-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i32.const 0)) (else (nop))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-both-value-void-vs-num (result i32) + (if (result i32) (i32.const 1) (then (nop)) (else (nop))) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-value-num-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i64.const 1)) (else (i32.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-then-value-num-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i32.const 1)) (else (i64.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-both-value-num-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i64.const 1)) (else (i64.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-both-different-value-num-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i64.const 1)) (else (f64.const 1))) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-value-unreached-select (result i32) + (if (result i64) + (i32.const 0) + (then (select (unreachable) (unreachable) (unreachable))) + (else (i64.const 0)) + ) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-value-unreached-select (result i32) + (if (result i64) + (i32.const 1) + (then (i64.const 0)) + (else (select (unreachable) (unreachable) (unreachable))) + ) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-value-unreached-select (result i32) + (if (result i64) + (i32.const 1) + (then (select (unreachable) (unreachable) (unreachable))) + (else (select (unreachable) (unreachable) (unreachable))) + ) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-break-last-void-vs-num (result i32) + (if (result i32) (i32.const 1) (then (br 0)) (else (i32.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-break-last-void-vs-num (result i32) + (if (result i32) (i32.const 1) (then (i32.const 1)) (else (br 0))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-then-break-empty-vs-num (result i32) + (if (result i32) (i32.const 1) + (then (br 0) (i32.const 1)) + (else (i32.const 1)) + ) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-break-empty-vs-num (result i32) + (if (result i32) (i32.const 1) + (then (i32.const 1)) + (else (br 0) (i32.const 1)) + ) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-then-break-void-vs-num (result i32) + (if (result i32) (i32.const 1) + (then (br 0 (nop)) (i32.const 1)) + (else (i32.const 1)) + ) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-break-void-vs-num (result i32) + (if (result i32) (i32.const 1) + (then (i32.const 1)) + (else (br 0 (nop)) (i32.const 1)) + ) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-then-break-num-vs-num (result i32) + (if (result i32) (i32.const 1) + (then (br 0 (i64.const 1)) (i32.const 1)) + (else (i32.const 1)) + ) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-else-break-num-vs-num (result i32) + (if (result i32) (i32.const 1) + (then (i32.const 1)) + (else (br 0 (i64.const 1)) (i32.const 1)) + ) + )) + "type mismatch" +) + + +(assert_malformed + (module quote "(func if end $l)") + "mismatching label" +) +(assert_malformed + (module quote "(func if $a end $l)") + "mismatching label" +) +(assert_malformed + (module quote "(func if else $l end)") + "mismatching label" +) +(assert_malformed + (module quote "(func if $a else $l end)") + "mismatching label" +) +(assert_malformed + (module quote "(func if else end $l)") + "mismatching label" +) +(assert_malformed + (module quote "(func if else $l end $l)") + "mismatching label" +) +(assert_malformed + (module quote "(func if else $l1 end $l2)") + "mismatching label" +) +(assert_malformed + (module quote "(func if $a else end $l)") + "mismatching label" +) +(assert_malformed + (module quote "(func if $a else $a end $l)") + "mismatching label" +) +(assert_malformed + (module quote "(func if $a else $l end $l)") + "mismatching label" +) diff --git a/src/spectests/return_.rs b/src/spectests/return_.rs new file mode 100644 index 000000000..6c9b6523e --- /dev/null +++ b/src/spectests/return_.rs @@ -0,0 +1,1238 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/return_.wast +#![allow( + warnings, + dead_code +)] +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export}; +use super::_common::spectest_importobject; +use wabt::wat2wasm; + + +// Line 3 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32 i32 i32) (result i32))) + (type (;1;) (func)) + (type (;2;) (func (result i32))) + (type (;3;) (func (result i64))) + (type (;4;) (func (result f32))) + (type (;5;) (func (result f64))) + (type (;6;) (func (param i32 i32) (result i32))) + (func (;0;) (type 1)) + (func (;1;) (type 1) + return + i32.ctz + drop) + (func (;2;) (type 1) + return + i64.ctz + drop) + (func (;3;) (type 1) + return + f32.neg + drop) + (func (;4;) (type 1) + return + f64.neg + drop) + (func (;5;) (type 2) (result i32) + block (result i32) ;; label = @1 + i32.const 1 + return + i32.ctz + end) + (func (;6;) (type 3) (result i64) + block (result i64) ;; label = @1 + i64.const 2 + return + i64.ctz + end) + (func (;7;) (type 4) (result f32) + block (result f32) ;; label = @1 + f32.const 0x1.8p+1 (;=3;) + return + f32.neg + end) + (func (;8;) (type 5) (result f64) + block (result f64) ;; label = @1 + f64.const 0x1p+2 (;=4;) + return + f64.neg + end) + (func (;9;) (type 1) + return) + (func (;10;) (type 5) (result f64) + f64.const 0x1.8p+1 (;=3;) + return) + (func (;11;) (type 2) (result i32) + i32.const 1 + return + i32.const 2) + (func (;12;) (type 2) (result i32) + call 0 + i32.const 2 + return + i32.const 3) + (func (;13;) (type 1) + nop + call 0 + return) + (func (;14;) (type 2) (result i32) + nop + call 0 + i32.const 3 + return) + (func (;15;) (type 1) + block ;; label = @1 + return + call 0 + end) + (func (;16;) (type 1) + block ;; label = @1 + call 0 + return + call 0 + end) + (func (;17;) (type 1) + block ;; label = @1 + nop + call 0 + return + end) + (func (;18;) (type 2) (result i32) + block (result i32) ;; label = @1 + nop + call 0 + i32.const 2 + return + end) + (func (;19;) (type 2) (result i32) + loop (result i32) ;; label = @1 + i32.const 3 + return + i32.const 2 + end) + (func (;20;) (type 2) (result i32) + loop (result i32) ;; label = @1 + call 0 + i32.const 4 + return + i32.const 2 + end) + (func (;21;) (type 2) (result i32) + loop (result i32) ;; label = @1 + nop + call 0 + i32.const 5 + return + end) + (func (;22;) (type 2) (result i32) + block (result i32) ;; label = @1 + i32.const 9 + return + br 0 (;@1;) + end) + (func (;23;) (type 1) + block ;; label = @1 + return + br_if 0 (;@1;) + end) + (func (;24;) (type 2) (result i32) + block (result i32) ;; label = @1 + i32.const 8 + return + i32.const 1 + br_if 0 (;@1;) + drop + i32.const 7 + end) + (func (;25;) (type 2) (result i32) + block (result i32) ;; label = @1 + i32.const 6 + i32.const 9 + return + br_if 0 (;@1;) + drop + i32.const 7 + end) + (func (;26;) (type 3) (result i64) + block ;; label = @1 + i64.const 9 + return + br_table 0 (;@1;) 0 (;@1;) 0 (;@1;) + end + i64.const -1) + (func (;27;) (type 2) (result i32) + block (result i32) ;; label = @1 + i32.const 10 + return + i32.const 1 + br_table 0 (;@1;) 0 (;@1;) 0 (;@1;) + i32.const 7 + end) + (func (;28;) (type 2) (result i32) + block (result i32) ;; label = @1 + i32.const 6 + i32.const 11 + return + br_table 0 (;@1;) 0 (;@1;) + i32.const 7 + end) + (func (;29;) (type 3) (result i64) + i64.const 7 + return + return) + (func (;30;) (type 2) (result i32) + i32.const 2 + return + if (result i32) ;; label = @1 + i32.const 0 + else + i32.const 1 + end) + (func (;31;) (type 6) (param i32 i32) (result i32) + get_local 0 + if (result i32) ;; label = @1 + i32.const 3 + return + else + get_local 1 + end) + (func (;32;) (type 6) (param i32 i32) (result i32) + get_local 0 + if (result i32) ;; label = @1 + get_local 1 + else + i32.const 4 + return + end) + (func (;33;) (type 6) (param i32 i32) (result i32) + i32.const 5 + return + get_local 0 + get_local 1 + select) + (func (;34;) (type 6) (param i32 i32) (result i32) + get_local 0 + i32.const 6 + return + get_local 1 + select) + (func (;35;) (type 2) (result i32) + i32.const 0 + i32.const 1 + i32.const 7 + return + select) + (func (;36;) (type 0) (param i32 i32 i32) (result i32) + i32.const -1) + (func (;37;) (type 2) (result i32) + i32.const 12 + return + i32.const 2 + i32.const 3 + call 36) + (func (;38;) (type 2) (result i32) + i32.const 1 + i32.const 13 + return + i32.const 3 + call 36) + (func (;39;) (type 2) (result i32) + i32.const 1 + i32.const 2 + i32.const 14 + return + call 36) + (func (;40;) (type 2) (result i32) + i32.const 20 + return + i32.const 1 + i32.const 2 + i32.const 3 + call_indirect (type 0)) + (func (;41;) (type 2) (result i32) + i32.const 0 + i32.const 21 + return + i32.const 2 + i32.const 3 + call_indirect (type 0)) + (func (;42;) (type 2) (result i32) + i32.const 0 + i32.const 1 + i32.const 22 + return + i32.const 3 + call_indirect (type 0)) + (func (;43;) (type 2) (result i32) + i32.const 0 + i32.const 1 + i32.const 2 + i32.const 23 + return + call_indirect (type 0)) + (func (;44;) (type 2) (result i32) + (local f32) + i32.const 17 + return + set_local 0 + i32.const -1) + (func (;45;) (type 4) (result f32) + f32.const 0x1.b33334p+0 (;=1.7;) + return + f32.load) + (func (;46;) (type 3) (result i64) + i64.const 30 + return + i64.load8_s) + (func (;47;) (type 2) (result i32) + i32.const 30 + return + f64.const 0x1.cp+2 (;=7;) + f64.store + i32.const -1) + (func (;48;) (type 2) (result i32) + i32.const 2 + i32.const 31 + return + i64.store + i32.const -1) + (func (;49;) (type 2) (result i32) + i32.const 32 + return + i32.const 7 + i32.store8 + i32.const -1) + (func (;50;) (type 2) (result i32) + i32.const 2 + i32.const 33 + return + i64.store16 + i32.const -1) + (func (;51;) (type 4) (result f32) + f32.const 0x1.b33334p+1 (;=3.4;) + return + f32.neg) + (func (;52;) (type 2) (result i32) + i32.const 3 + return + i32.const 10 + i32.add) + (func (;53;) (type 3) (result i64) + i64.const 10 + i64.const 45 + return + i64.sub) + (func (;54;) (type 2) (result i32) + i32.const 44 + return + i32.eqz) + (func (;55;) (type 2) (result i32) + i32.const 43 + return + f64.const 0x1.4p+3 (;=10;) + f64.le) + (func (;56;) (type 2) (result i32) + f32.const 0x1.4p+3 (;=10;) + i32.const 42 + return + f32.ne) + (func (;57;) (type 2) (result i32) + i32.const 41 + return + i32.wrap/i64) + (func (;58;) (type 2) (result i32) + i32.const 40 + return + memory.grow) + (table (;0;) 1 1 anyfunc) + (memory (;0;) 1) + (export \"type-i32\" (func 1)) + (export \"type-i64\" (func 2)) + (export \"type-f32\" (func 3)) + (export \"type-f64\" (func 4)) + (export \"type-i32-value\" (func 5)) + (export \"type-i64-value\" (func 6)) + (export \"type-f32-value\" (func 7)) + (export \"type-f64-value\" (func 8)) + (export \"nullary\" (func 9)) + (export \"unary\" (func 10)) + (export \"as-func-first\" (func 11)) + (export \"as-func-mid\" (func 12)) + (export \"as-func-last\" (func 13)) + (export \"as-func-value\" (func 14)) + (export \"as-block-first\" (func 15)) + (export \"as-block-mid\" (func 16)) + (export \"as-block-last\" (func 17)) + (export \"as-block-value\" (func 18)) + (export \"as-loop-first\" (func 19)) + (export \"as-loop-mid\" (func 20)) + (export \"as-loop-last\" (func 21)) + (export \"as-br-value\" (func 22)) + (export \"as-br_if-cond\" (func 23)) + (export \"as-br_if-value\" (func 24)) + (export \"as-br_if-value-cond\" (func 25)) + (export \"as-br_table-index\" (func 26)) + (export \"as-br_table-value\" (func 27)) + (export \"as-br_table-value-index\" (func 28)) + (export \"as-return-value\" (func 29)) + (export \"as-if-cond\" (func 30)) + (export \"as-if-then\" (func 31)) + (export \"as-if-else\" (func 32)) + (export \"as-select-first\" (func 33)) + (export \"as-select-second\" (func 34)) + (export \"as-select-cond\" (func 35)) + (export \"as-call-first\" (func 37)) + (export \"as-call-mid\" (func 38)) + (export \"as-call-last\" (func 39)) + (export \"as-call_indirect-func\" (func 40)) + (export \"as-call_indirect-first\" (func 41)) + (export \"as-call_indirect-mid\" (func 42)) + (export \"as-call_indirect-last\" (func 43)) + (export \"as-set_local-value\" (func 44)) + (export \"as-load-address\" (func 45)) + (export \"as-loadN-address\" (func 46)) + (export \"as-store-address\" (func 47)) + (export \"as-store-value\" (func 48)) + (export \"as-storeN-address\" (func 49)) + (export \"as-storeN-value\" (func 50)) + (export \"as-unary-operand\" (func 51)) + (export \"as-binary-left\" (func 52)) + (export \"as-binary-right\" (func 53)) + (export \"as-test-operand\" (func 54)) + (export \"as-compare-left\" (func 55)) + (export \"as-compare-right\" (func 56)) + (export \"as-convert-operand\" (func 57)) + (export \"as-memory.grow-size\" (func 58)) + (elem (i32.const 0) 36)) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 217 +fn l217_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l217_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-i32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 218 +fn l218_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l218_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-i64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 219 +fn l219_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l219_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 220 +fn l220_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l220_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 222 +fn l222_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l222_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-i32-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 223 +fn l223_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l223_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-i64-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2 as i64); +} + +// Line 224 +fn l224_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l224_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-f32-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3.0 as f32); +} + +// Line 225 +fn l225_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l225_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-f64-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4.0 as f64); +} + +// Line 227 +fn l227_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l227_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("nullary") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 228 +fn l228_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l228_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("unary") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3.0 as f64); +} + +// Line 230 +fn l230_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l230_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-func-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 231 +fn l231_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l231_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-func-mid") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2 as i32); +} + +// Line 232 +fn l232_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l232_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-func-last") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 233 +fn l233_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l233_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-func-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3 as i32); +} + +// Line 235 +fn l235_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l235_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-block-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 236 +fn l236_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l236_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-block-mid") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 237 +fn l237_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l237_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-block-last") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 238 +fn l238_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l238_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-block-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2 as i32); +} + +// Line 240 +fn l240_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l240_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-loop-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3 as i32); +} + +// Line 241 +fn l241_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l241_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-loop-mid") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 4 as i32); +} + +// Line 242 +fn l242_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l242_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-loop-last") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 5 as i32); +} + +// Line 244 +fn l244_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l244_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9 as i32); +} + +// Line 246 +fn l246_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l246_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br_if-cond") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, ()); +} + +// Line 247 +fn l247_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l247_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br_if-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 8 as i32); +} + +// Line 248 +fn l248_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l248_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br_if-value-cond") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9 as i32); +} + +// Line 250 +fn l250_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l250_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br_table-index") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 9 as i64); +} + +// Line 251 +fn l251_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l251_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br_table-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 10 as i32); +} + +// Line 252 +fn l252_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l252_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-br_table-value-index") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 11 as i32); +} + +// Line 254 +fn l254_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l254_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-return-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 7 as i64); +} + +// Line 256 +fn l256_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l256_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-if-cond") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 2 as i32); +} + +// Line 257 +fn l257_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l257_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-if-then") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 6 as i32, &vm_context); + assert_eq!(result, 3 as i32); +} + +// Line 258 +fn l258_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l258_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-if-then") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i32, 6 as i32, &vm_context); + assert_eq!(result, 6 as i32); +} + +// Line 259 +fn l259_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l259_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-if-else") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i32, 6 as i32, &vm_context); + assert_eq!(result, 4 as i32); +} + +// Line 260 +fn l260_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l260_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-if-else") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 6 as i32, &vm_context); + assert_eq!(result, 6 as i32); +} + +// Line 262 +fn l262_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l262_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-select-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i32, 6 as i32, &vm_context); + assert_eq!(result, 5 as i32); +} + +// Line 263 +fn l263_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l263_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-select-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 6 as i32, &vm_context); + assert_eq!(result, 5 as i32); +} + +// Line 264 +fn l264_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l264_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-select-second") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i32, 6 as i32, &vm_context); + assert_eq!(result, 6 as i32); +} + +// Line 265 +fn l265_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l265_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-select-second") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 6 as i32, &vm_context); + assert_eq!(result, 6 as i32); +} + +// Line 266 +fn l266_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l266_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-select-cond") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 7 as i32); +} + +// Line 268 +fn l268_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l268_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 12 as i32); +} + +// Line 269 +fn l269_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l269_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call-mid") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 13 as i32); +} + +// Line 270 +fn l270_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l270_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call-last") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 14 as i32); +} + +// Line 272 +fn l272_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l272_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call_indirect-func") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 20 as i32); +} + +// Line 273 +fn l273_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l273_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call_indirect-first") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 21 as i32); +} + +// Line 274 +fn l274_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l274_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call_indirect-mid") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 22 as i32); +} + +// Line 275 +fn l275_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l275_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-call_indirect-last") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 23 as i32); +} + +// Line 277 +fn l277_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l277_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-set_local-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 17 as i32); +} + +// Line 279 +fn l279_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l279_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-load-address") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1.7 as f32); +} + +// Line 280 +fn l280_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l280_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-loadN-address") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 30 as i64); +} + +// Line 282 +fn l282_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l282_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-store-address") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 30 as i32); +} + +// Line 283 +fn l283_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l283_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-store-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 31 as i32); +} + +// Line 284 +fn l284_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l284_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-storeN-address") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 32 as i32); +} + +// Line 285 +fn l285_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l285_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-storeN-value") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 33 as i32); +} + +// Line 287 +fn l287_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l287_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-unary-operand") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3.4 as f32); +} + +// Line 289 +fn l289_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l289_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-binary-left") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 3 as i32); +} + +// Line 290 +fn l290_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l290_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-binary-right") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 45 as i64); +} + +// Line 292 +fn l292_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l292_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-test-operand") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 44 as i32); +} + +// Line 294 +fn l294_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l294_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-compare-left") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 43 as i32); +} + +// Line 295 +fn l295_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l295_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-compare-right") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 42 as i32); +} + +// Line 297 +fn l297_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l297_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-convert-operand") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 41 as i32); +} + +// Line 299 +fn l299_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l299_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("as-memory.grow-size") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 40 as i32); +} + +// Line 302 +#[test] +fn l302_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 124, 3, 2, 1, 0, 10, 5, 1, 3, 0, 15, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 306 +#[test] +fn l306_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 124, 3, 2, 1, 0, 10, 6, 1, 4, 0, 1, 15, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 310 +#[test] +fn l310_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 124, 3, 2, 1, 0, 10, 7, 1, 5, 0, 66, 1, 15, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l217_assert_return_invoke(&result_object, &vm_context); + l218_assert_return_invoke(&result_object, &vm_context); + l219_assert_return_invoke(&result_object, &vm_context); + l220_assert_return_invoke(&result_object, &vm_context); + l222_assert_return_invoke(&result_object, &vm_context); + l223_assert_return_invoke(&result_object, &vm_context); + l224_assert_return_invoke(&result_object, &vm_context); + l225_assert_return_invoke(&result_object, &vm_context); + l227_assert_return_invoke(&result_object, &vm_context); + l228_assert_return_invoke(&result_object, &vm_context); + l230_assert_return_invoke(&result_object, &vm_context); + l231_assert_return_invoke(&result_object, &vm_context); + l232_assert_return_invoke(&result_object, &vm_context); + l233_assert_return_invoke(&result_object, &vm_context); + l235_assert_return_invoke(&result_object, &vm_context); + l236_assert_return_invoke(&result_object, &vm_context); + l237_assert_return_invoke(&result_object, &vm_context); + l238_assert_return_invoke(&result_object, &vm_context); + l240_assert_return_invoke(&result_object, &vm_context); + l241_assert_return_invoke(&result_object, &vm_context); + l242_assert_return_invoke(&result_object, &vm_context); + l244_assert_return_invoke(&result_object, &vm_context); + l246_assert_return_invoke(&result_object, &vm_context); + l247_assert_return_invoke(&result_object, &vm_context); + l248_assert_return_invoke(&result_object, &vm_context); + l250_assert_return_invoke(&result_object, &vm_context); + l251_assert_return_invoke(&result_object, &vm_context); + l252_assert_return_invoke(&result_object, &vm_context); + l254_assert_return_invoke(&result_object, &vm_context); + l256_assert_return_invoke(&result_object, &vm_context); + l257_assert_return_invoke(&result_object, &vm_context); + l258_assert_return_invoke(&result_object, &vm_context); + l259_assert_return_invoke(&result_object, &vm_context); + l260_assert_return_invoke(&result_object, &vm_context); + l262_assert_return_invoke(&result_object, &vm_context); + l263_assert_return_invoke(&result_object, &vm_context); + l264_assert_return_invoke(&result_object, &vm_context); + l265_assert_return_invoke(&result_object, &vm_context); + l266_assert_return_invoke(&result_object, &vm_context); + l268_assert_return_invoke(&result_object, &vm_context); + l269_assert_return_invoke(&result_object, &vm_context); + l270_assert_return_invoke(&result_object, &vm_context); + l272_assert_return_invoke(&result_object, &vm_context); + l273_assert_return_invoke(&result_object, &vm_context); + l274_assert_return_invoke(&result_object, &vm_context); + l275_assert_return_invoke(&result_object, &vm_context); + l277_assert_return_invoke(&result_object, &vm_context); + l279_assert_return_invoke(&result_object, &vm_context); + l280_assert_return_invoke(&result_object, &vm_context); + l282_assert_return_invoke(&result_object, &vm_context); + l283_assert_return_invoke(&result_object, &vm_context); + l284_assert_return_invoke(&result_object, &vm_context); + l285_assert_return_invoke(&result_object, &vm_context); + l287_assert_return_invoke(&result_object, &vm_context); + l289_assert_return_invoke(&result_object, &vm_context); + l290_assert_return_invoke(&result_object, &vm_context); + l292_assert_return_invoke(&result_object, &vm_context); + l294_assert_return_invoke(&result_object, &vm_context); + l295_assert_return_invoke(&result_object, &vm_context); + l297_assert_return_invoke(&result_object, &vm_context); + l299_assert_return_invoke(&result_object, &vm_context); +} diff --git a/src/spectests/select.rs b/src/spectests/select.rs new file mode 100644 index 000000000..d97006287 --- /dev/null +++ b/src/spectests/select.rs @@ -0,0 +1,420 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/select.wast +#![allow( + warnings, + dead_code +)] +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export}; +use super::_common::spectest_importobject; +use wabt::wat2wasm; + + +// Line 1 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32 i32 i32) (result i32))) + (type (;1;) (func (param i64 i64 i32) (result i64))) + (type (;2;) (func (param f32 f32 i32) (result f32))) + (type (;3;) (func (param f64 f64 i32) (result f64))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func)) + (func (;0;) (type 0) (param i32 i32 i32) (result i32) + get_local 0 + get_local 1 + get_local 2 + select) + (func (;1;) (type 1) (param i64 i64 i32) (result i64) + get_local 0 + get_local 1 + get_local 2 + select) + (func (;2;) (type 2) (param f32 f32 i32) (result f32) + get_local 0 + get_local 1 + get_local 2 + select) + (func (;3;) (type 3) (param f64 f64 i32) (result f64) + get_local 0 + get_local 1 + get_local 2 + select) + (func (;4;) (type 4) (param i32) (result i32) + unreachable + i32.const 0 + get_local 0 + select) + (func (;5;) (type 4) (param i32) (result i32) + i32.const 0 + unreachable + get_local 0 + select) + (func (;6;) (type 5) + unreachable + select + unreachable + i32.const 0 + select + unreachable + i32.const 0 + i32.const 0 + select + unreachable + f32.const 0x0p+0 (;=0;) + i32.const 0 + select + unreachable) + (export \"select_i32\" (func 0)) + (export \"select_i64\" (func 1)) + (export \"select_f32\" (func 2)) + (export \"select_f64\" (func 3)) + (export \"select_trap_l\" (func 4)) + (export \"select_trap_r\" (func 5)) + (export \"select_unreached\" (func 6))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 31 +fn l31_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l31_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_i32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 2 as i32, 1 as i32, &vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 32 +fn l32_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l32_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_i64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, i32, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i64, 1 as i64, 1 as i32, &vm_context); + assert_eq!(result, 2 as i64); +} + +// Line 33 +fn l33_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l33_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1.0 as f32, 2.0 as f32, 1 as i32, &vm_context); + assert_eq!(result, 1.0 as f32); +} + +// Line 34 +fn l34_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l34_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1.0 as f64, 2.0 as f64, 1 as i32, &vm_context); + assert_eq!(result, 1.0 as f64); +} + +// Line 36 +fn l36_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l36_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_i32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 2 as i32, 0 as i32, &vm_context); + assert_eq!(result, 2 as i32); +} + +// Line 37 +fn l37_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l37_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_i32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i32, 1 as i32, 0 as i32, &vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 38 +fn l38_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l38_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_i64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, i32, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i64, 1 as i64, -1 as i32, &vm_context); + assert_eq!(result, 2 as i64); +} + +// Line 39 +fn l39_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l39_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_i64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, i32, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i64, 1 as i64, -252645136 as i32, &vm_context); + assert_eq!(result, 2 as i64); +} + +// Line 41 +fn l41_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l41_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f32::NAN, 1.0 as f32, 1 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f32::NAN).is_sign_positive()); +} + +// Line 42 +fn l42_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l42_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f32::NAN, 1.0 as f32, 1 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f32::NAN).is_sign_positive()); +} + +// Line 43 +fn l43_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l43_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f32::NAN, 1.0 as f32, 0 as i32, &vm_context); + assert_eq!(result, 1.0 as f32); +} + +// Line 44 +fn l44_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l44_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f32::NAN, 1.0 as f32, 0 as i32, &vm_context); + assert_eq!(result, 1.0 as f32); +} + +// Line 45 +fn l45_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l45_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f32, std::f32::NAN, 1 as i32, &vm_context); + assert_eq!(result, 2.0 as f32); +} + +// Line 46 +fn l46_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l46_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f32, std::f32::NAN, 1 as i32, &vm_context); + assert_eq!(result, 2.0 as f32); +} + +// Line 47 +fn l47_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l47_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f32, std::f32::NAN, 0 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f32::NAN).is_sign_positive()); +} + +// Line 48 +fn l48_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l48_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, f32, i32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f32, std::f32::NAN, 0 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f32::NAN).is_sign_positive()); +} + +// Line 50 +fn l50_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l50_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f64::NAN, 1.0 as f64, 1 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f64::NAN).is_sign_positive()); +} + +// Line 51 +fn l51_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l51_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f64::NAN, 1.0 as f64, 1 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f64::NAN).is_sign_positive()); +} + +// Line 52 +fn l52_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l52_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f64::NAN, 1.0 as f64, 0 as i32, &vm_context); + assert_eq!(result, 1.0 as f64); +} + +// Line 53 +fn l53_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l53_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(std::f64::NAN, 1.0 as f64, 0 as i32, &vm_context); + assert_eq!(result, 1.0 as f64); +} + +// Line 54 +fn l54_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l54_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f64, std::f64::NAN, 1 as i32, &vm_context); + assert_eq!(result, 2.0 as f64); +} + +// Line 55 +fn l55_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l55_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f64, std::f64::NAN, 1 as i32, &vm_context); + assert_eq!(result, 2.0 as f64); +} + +// Line 56 +fn l56_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l56_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f64, std::f64::NAN, 0 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f64::NAN).is_sign_positive()); +} + +// Line 57 +fn l57_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l57_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("select_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, f64, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2.0 as f64, std::f64::NAN, 0 as i32, &vm_context); + assert!(result.is_nan()); + assert_eq!(result.is_sign_positive(), (std::f64::NAN).is_sign_positive()); +} + +// Line 59 + +// Line 60 + +// Line 61 + +// Line 62 + +// Line 65 +#[test] +fn l65_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 1, 1, 65, 1, 27, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l31_assert_return_invoke(&result_object, &vm_context); + l32_assert_return_invoke(&result_object, &vm_context); + l33_assert_return_invoke(&result_object, &vm_context); + l34_assert_return_invoke(&result_object, &vm_context); + l36_assert_return_invoke(&result_object, &vm_context); + l37_assert_return_invoke(&result_object, &vm_context); + l38_assert_return_invoke(&result_object, &vm_context); + l39_assert_return_invoke(&result_object, &vm_context); + l41_assert_return_invoke(&result_object, &vm_context); + l42_assert_return_invoke(&result_object, &vm_context); + l43_assert_return_invoke(&result_object, &vm_context); + l44_assert_return_invoke(&result_object, &vm_context); + l45_assert_return_invoke(&result_object, &vm_context); + l46_assert_return_invoke(&result_object, &vm_context); + l47_assert_return_invoke(&result_object, &vm_context); + l48_assert_return_invoke(&result_object, &vm_context); + l50_assert_return_invoke(&result_object, &vm_context); + l51_assert_return_invoke(&result_object, &vm_context); + l52_assert_return_invoke(&result_object, &vm_context); + l53_assert_return_invoke(&result_object, &vm_context); + l54_assert_return_invoke(&result_object, &vm_context); + l55_assert_return_invoke(&result_object, &vm_context); + l56_assert_return_invoke(&result_object, &vm_context); + l57_assert_return_invoke(&result_object, &vm_context); +} diff --git a/src/spectests/switch.rs b/src/spectests/switch.rs new file mode 100644 index 000000000..cf25b84b7 --- /dev/null +++ b/src/spectests/switch.rs @@ -0,0 +1,492 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/switch.wast +#![allow( + warnings, + dead_code +)] +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export}; +use super::_common::spectest_importobject; +use wabt::wat2wasm; + + +// Line 1 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i64) (result i64))) + (type (;2;) (func (result i32))) + (func (;0;) (type 0) (param i32) (result i32) + (local i32) + i32.const 100 + set_local 1 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + get_local 0 + br_table 0 (;@10;) 1 (;@9;) 2 (;@8;) 3 (;@7;) 4 (;@6;) 5 (;@5;) 6 (;@4;) 8 (;@2;) 7 (;@3;) + end + get_local 0 + return + end + nop + end + end + i32.const 0 + get_local 0 + i32.sub + set_local 1 + br 5 (;@1;) + end + br 4 (;@1;) + end + i32.const 101 + set_local 1 + br 3 (;@1;) + end + i32.const 101 + set_local 1 + end + i32.const 102 + set_local 1 + end + end + get_local 1 + return) + (func (;1;) (type 1) (param i64) (result i64) + (local i64) + i64.const 100 + set_local 1 + block (result i64) ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + get_local 0 + i32.wrap/i64 + br_table 0 (;@10;) 1 (;@9;) 2 (;@8;) 3 (;@7;) 6 (;@4;) 5 (;@5;) 4 (;@6;) 8 (;@2;) 7 (;@3;) + end + get_local 0 + return + end + nop + end + end + i64.const 0 + get_local 0 + i64.sub + br 5 (;@1;) + end + i64.const 101 + set_local 1 + end + end + end + get_local 1 + br 1 (;@1;) + end + i64.const -5 + end + return) + (func (;2;) (type 0) (param i32) (result i32) + block (result i32) ;; label = @1 + i32.const 10 + block (result i32) ;; label = @2 + i32.const 100 + block (result i32) ;; label = @3 + i32.const 1000 + block (result i32) ;; label = @4 + i32.const 2 + get_local 0 + i32.mul + i32.const 3 + get_local 0 + i32.and + br_table 1 (;@3;) 2 (;@2;) 3 (;@1;) 0 (;@4;) + end + i32.add + end + i32.add + end + i32.add + end + return) + (func (;3;) (type 2) (result i32) + block ;; label = @1 + i32.const 0 + br_table 0 (;@1;) + end + i32.const 1) + (export \"stmt\" (func 0)) + (export \"expr\" (func 1)) + (export \"arg\" (func 2)) + (export \"corner\" (func 3))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 120 +fn l120_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l120_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i32, &vm_context); + assert_eq!(result, 0 as i32); +} + +// Line 121 +fn l121_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l121_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, &vm_context); + assert_eq!(result, -1 as i32); +} + +// Line 122 +fn l122_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l122_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i32, &vm_context); + assert_eq!(result, -2 as i32); +} + +// Line 123 +fn l123_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l123_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(3 as i32, &vm_context); + assert_eq!(result, -3 as i32); +} + +// Line 124 +fn l124_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l124_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(4 as i32, &vm_context); + assert_eq!(result, 100 as i32); +} + +// Line 125 +fn l125_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l125_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(5 as i32, &vm_context); + assert_eq!(result, 101 as i32); +} + +// Line 126 +fn l126_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l126_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(6 as i32, &vm_context); + assert_eq!(result, 102 as i32); +} + +// Line 127 +fn l127_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l127_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(7 as i32, &vm_context); + assert_eq!(result, 100 as i32); +} + +// Line 128 +fn l128_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l128_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("stmt") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-10 as i32, &vm_context); + assert_eq!(result, 102 as i32); +} + +// Line 130 +fn l130_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l130_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i64, &vm_context); + assert_eq!(result, 0 as i64); +} + +// Line 131 +fn l131_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l131_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, &vm_context); + assert_eq!(result, -1 as i64); +} + +// Line 132 +fn l132_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l132_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i64, &vm_context); + assert_eq!(result, -2 as i64); +} + +// Line 133 +fn l133_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l133_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(3 as i64, &vm_context); + assert_eq!(result, -3 as i64); +} + +// Line 134 +fn l134_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l134_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(6 as i64, &vm_context); + assert_eq!(result, 101 as i64); +} + +// Line 135 +fn l135_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l135_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(7 as i64, &vm_context); + assert_eq!(result, -5 as i64); +} + +// Line 136 +fn l136_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l136_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("expr") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-10 as i64, &vm_context); + assert_eq!(result, 100 as i64); +} + +// Line 138 +fn l138_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l138_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(0 as i32, &vm_context); + assert_eq!(result, 110 as i32); +} + +// Line 139 +fn l139_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l139_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, &vm_context); + assert_eq!(result, 12 as i32); +} + +// Line 140 +fn l140_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l140_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i32, &vm_context); + assert_eq!(result, 4 as i32); +} + +// Line 141 +fn l141_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l141_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(3 as i32, &vm_context); + assert_eq!(result, 1116 as i32); +} + +// Line 142 +fn l142_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l142_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(4 as i32, &vm_context); + assert_eq!(result, 118 as i32); +} + +// Line 143 +fn l143_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l143_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(5 as i32, &vm_context); + assert_eq!(result, 20 as i32); +} + +// Line 144 +fn l144_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l144_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(6 as i32, &vm_context); + assert_eq!(result, 12 as i32); +} + +// Line 145 +fn l145_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l145_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(7 as i32, &vm_context); + assert_eq!(result, 1124 as i32); +} + +// Line 146 +fn l146_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l146_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("arg") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(8 as i32, &vm_context); + assert_eq!(result, 126 as i32); +} + +// Line 148 +fn l148_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l148_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("corner") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 1 as i32); +} + +// Line 150 +#[test] +fn l150_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 14, 0, 3, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l120_assert_return_invoke(&result_object, &vm_context); + l121_assert_return_invoke(&result_object, &vm_context); + l122_assert_return_invoke(&result_object, &vm_context); + l123_assert_return_invoke(&result_object, &vm_context); + l124_assert_return_invoke(&result_object, &vm_context); + l125_assert_return_invoke(&result_object, &vm_context); + l126_assert_return_invoke(&result_object, &vm_context); + l127_assert_return_invoke(&result_object, &vm_context); + l128_assert_return_invoke(&result_object, &vm_context); + l130_assert_return_invoke(&result_object, &vm_context); + l131_assert_return_invoke(&result_object, &vm_context); + l132_assert_return_invoke(&result_object, &vm_context); + l133_assert_return_invoke(&result_object, &vm_context); + l134_assert_return_invoke(&result_object, &vm_context); + l135_assert_return_invoke(&result_object, &vm_context); + l136_assert_return_invoke(&result_object, &vm_context); + l138_assert_return_invoke(&result_object, &vm_context); + l139_assert_return_invoke(&result_object, &vm_context); + l140_assert_return_invoke(&result_object, &vm_context); + l141_assert_return_invoke(&result_object, &vm_context); + l142_assert_return_invoke(&result_object, &vm_context); + l143_assert_return_invoke(&result_object, &vm_context); + l144_assert_return_invoke(&result_object, &vm_context); + l145_assert_return_invoke(&result_object, &vm_context); + l146_assert_return_invoke(&result_object, &vm_context); + l148_assert_return_invoke(&result_object, &vm_context); +} diff --git a/src/spectests/tee_local.rs b/src/spectests/tee_local.rs new file mode 100644 index 000000000..f7c1a7c6b --- /dev/null +++ b/src/spectests/tee_local.rs @@ -0,0 +1,521 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/tee_local.wast +#![allow( + warnings, + dead_code +)] +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, VmCtx, Export}; +use super::_common::spectest_importobject; +use wabt::wat2wasm; + + +// Line 3 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (result i32))) + (type (;1;) (func (result i64))) + (type (;2;) (func (result f32))) + (type (;3;) (func (result f64))) + (type (;4;) (func (param i32) (result i32))) + (type (;5;) (func (param i64) (result i64))) + (type (;6;) (func (param f32) (result f32))) + (type (;7;) (func (param f64) (result f64))) + (type (;8;) (func (param i64 f32 f64 i32 i32))) + (type (;9;) (func (param i64 f32 f64 i32 i32) (result i64))) + (type (;10;) (func (param i64 f32 f64 i32 i32) (result f64))) + (func (;0;) (type 0) (result i32) + (local i32) + i32.const 0 + tee_local 0) + (func (;1;) (type 1) (result i64) + (local i64) + i64.const 0 + tee_local 0) + (func (;2;) (type 2) (result f32) + (local f32) + f32.const 0x0p+0 (;=0;) + tee_local 0) + (func (;3;) (type 3) (result f64) + (local f64) + f64.const 0x0p+0 (;=0;) + tee_local 0) + (func (;4;) (type 4) (param i32) (result i32) + i32.const 10 + tee_local 0) + (func (;5;) (type 5) (param i64) (result i64) + i64.const 11 + tee_local 0) + (func (;6;) (type 6) (param f32) (result f32) + f32.const 0x1.633334p+3 (;=11.1;) + tee_local 0) + (func (;7;) (type 7) (param f64) (result f64) + f64.const 0x1.8666666666666p+3 (;=12.2;) + tee_local 0) + (func (;8;) (type 8) (param i64 f32 f64 i32 i32) + (local f32 i64 i64 f64) + i64.const 0 + tee_local 0 + i64.eqz + drop + f32.const 0x0p+0 (;=0;) + tee_local 1 + f32.neg + drop + f64.const 0x0p+0 (;=0;) + tee_local 2 + f64.neg + drop + i32.const 0 + tee_local 3 + i32.eqz + drop + i32.const 0 + tee_local 4 + i32.eqz + drop + f32.const 0x0p+0 (;=0;) + tee_local 5 + f32.neg + drop + i64.const 0 + tee_local 6 + i64.eqz + drop + i64.const 0 + tee_local 7 + i64.eqz + drop + f64.const 0x0p+0 (;=0;) + tee_local 8 + f64.neg + drop) + (func (;9;) (type 9) (param i64 f32 f64 i32 i32) (result i64) + (local f32 i64 i64 f64) + f32.const -0x1.333334p-2 (;=-0.3;) + tee_local 1 + drop + i32.const 40 + tee_local 3 + drop + i32.const -7 + tee_local 4 + drop + f32.const 0x1.6p+2 (;=5.5;) + tee_local 5 + drop + i64.const 6 + tee_local 6 + drop + f64.const 0x1p+3 (;=8;) + tee_local 8 + drop + get_local 0 + f64.convert_u/i64 + get_local 1 + f64.promote/f32 + get_local 2 + get_local 3 + f64.convert_u/i32 + get_local 4 + f64.convert_s/i32 + get_local 5 + f64.promote/f32 + get_local 6 + f64.convert_u/i64 + get_local 7 + f64.convert_u/i64 + get_local 8 + f64.add + f64.add + f64.add + f64.add + f64.add + f64.add + f64.add + f64.add + i64.trunc_s/f64) + (func (;10;) (type 10) (param i64 f32 f64 i32 i32) (result f64) + (local f32 i64 i64 f64) + i64.const 1 + tee_local 0 + f64.convert_u/i64 + f32.const 0x1p+1 (;=2;) + tee_local 1 + f64.promote/f32 + f64.const 0x1.a666666666666p+1 (;=3.3;) + tee_local 2 + i32.const 4 + tee_local 3 + f64.convert_u/i32 + i32.const 5 + tee_local 4 + f64.convert_s/i32 + f32.const 0x1.6p+2 (;=5.5;) + tee_local 5 + f64.promote/f32 + i64.const 6 + tee_local 6 + f64.convert_u/i64 + i64.const 0 + tee_local 7 + f64.convert_u/i64 + f64.const 0x1p+3 (;=8;) + tee_local 8 + f64.add + f64.add + f64.add + f64.add + f64.add + f64.add + f64.add + f64.add) + (export \"type-local-i32\" (func 0)) + (export \"type-local-i64\" (func 1)) + (export \"type-local-f32\" (func 2)) + (export \"type-local-f64\" (func 3)) + (export \"type-param-i32\" (func 4)) + (export \"type-param-i64\" (func 5)) + (export \"type-param-f32\" (func 6)) + (export \"type-param-f64\" (func 7)) + (export \"type-mixed\" (func 8)) + (export \"write\" (func 9)) + (export \"result\" (func 10))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +// Line 98 +fn l98_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l98_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-local-i32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i32); +} + +// Line 99 +fn l99_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l99_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-local-i64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0 as i64); +} + +// Line 100 +fn l100_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l100_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-local-f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0.0 as f32); +} + +// Line 101 +fn l101_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l101_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-local-f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(&VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(&vm_context); + assert_eq!(result, 0.0 as f64); +} + +// Line 103 +fn l103_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l103_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-param-i32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &VmCtx) -> i32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(2 as i32, &vm_context); + assert_eq!(result, 10 as i32); +} + +// Line 104 +fn l104_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l104_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-param-i64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(3 as i64, &vm_context); + assert_eq!(result, 11 as i64); +} + +// Line 105 +fn l105_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l105_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-param-f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &VmCtx) -> f32 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(4.4 as f32, &vm_context); + assert_eq!(result, 11.1 as f32); +} + +// Line 106 +fn l106_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l106_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-param-f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(5.5 as f64, &vm_context); + assert_eq!(result, 12.2 as f64); +} + +// Line 109 +fn l109_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l109_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("type-mixed") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, f32, f64, i32, i32, &VmCtx) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, 2.2 as f32, 3.3 as f64, 4 as i32, 5 as i32, &vm_context); + assert_eq!(result, ()); +} + +// Line 115 +fn l115_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l115_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("write") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, f32, f64, i32, i32, &VmCtx) -> i64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, 2.0 as f32, 3.3 as f64, 4 as i32, 5 as i32, &vm_context); + assert_eq!(result, 56 as i64); +} + +// Line 122 +fn l122_assert_return_invoke(result_object: &ResultObject, vm_context: &VmCtx) { + println!("Executing function {}", "l122_assert_return_invoke"); + let func_index = match result_object.module.info.exports.get("result") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, f32, f64, i32, i32, &VmCtx) -> f64 = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-1 as i64, -2.0 as f32, -3.3 as f64, -4 as i32, -5 as i32, &vm_context); + assert_eq!(result, 34.8 as f64); +} + +// Line 132 +#[test] +fn l132_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 126, 3, 2, 1, 0, 10, 10, 1, 8, 1, 1, 127, 65, 0, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 136 +#[test] +fn l136_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 14, 1, 12, 1, 1, 125, 67, 0, 0, 0, 0, 34, 0, 69, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 140 +#[test] +fn l140_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 13, 1, 11, 2, 1, 124, 1, 126, 66, 0, 34, 1, 154, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 145 +#[test] +fn l145_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 1, 1, 127, 1, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 149 +#[test] +fn l149_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 13, 1, 11, 1, 1, 127, 67, 0, 0, 0, 0, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 153 +#[test] +fn l153_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 17, 1, 15, 1, 1, 125, 68, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 157 +#[test] +fn l157_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 19, 1, 17, 2, 1, 124, 1, 126, 68, 0, 0, 0, 0, 0, 0, 0, 0, 34, 1, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 165 +#[test] +fn l165_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 126, 3, 2, 1, 0, 10, 6, 1, 4, 0, 32, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 169 +#[test] +fn l169_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 125, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 32, 0, 69, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 173 +#[test] +fn l173_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 124, 126, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 32, 1, 154, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 178 +#[test] +fn l178_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 127, 0, 3, 2, 1, 0, 10, 7, 1, 5, 0, 1, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 182 +#[test] +fn l182_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 127, 0, 3, 2, 1, 0, 10, 11, 1, 9, 0, 67, 0, 0, 0, 0, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 186 +#[test] +fn l186_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 125, 0, 3, 2, 1, 0, 10, 15, 1, 13, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 190 +#[test] +fn l190_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 124, 126, 0, 3, 2, 1, 0, 10, 15, 1, 13, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 34, 1, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 198 +#[test] +fn l198_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 10, 1, 8, 2, 1, 127, 1, 126, 32, 3, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 202 +#[test] +fn l202_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 13, 1, 11, 2, 1, 127, 1, 126, 32, 247, 164, 234, 6, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 207 +#[test] +fn l207_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 127, 126, 0, 3, 2, 1, 0, 10, 6, 1, 4, 0, 32, 2, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 211 +#[test] +fn l211_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 14, 1, 12, 2, 1, 127, 1, 126, 32, 247, 242, 206, 212, 2, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 216 +#[test] +fn l216_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 127, 0, 3, 2, 1, 0, 10, 10, 1, 8, 2, 1, 127, 1, 126, 32, 3, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 220 +#[test] +fn l220_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 126, 0, 3, 2, 1, 0, 10, 13, 1, 11, 2, 1, 127, 1, 126, 32, 247, 168, 153, 102, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 225 +#[test] +fn l225_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 125, 0, 3, 2, 1, 0, 10, 13, 1, 11, 1, 1, 127, 67, 0, 0, 0, 0, 34, 1, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 229 +#[test] +fn l229_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 2, 126, 127, 0, 3, 2, 1, 0, 10, 13, 1, 11, 1, 1, 125, 67, 0, 0, 0, 0, 34, 1, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +// Line 233 +#[test] +fn l233_assert_invalid() { + let wasm_binary = [0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 1, 126, 0, 3, 2, 1, 0, 10, 12, 1, 10, 2, 1, 124, 1, 126, 66, 0, 34, 1, 11]; + let compilation = compile(wasm_binary.to_vec()); + assert!(compilation.is_err(), "WASM should not compile as is invalid"); +} + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + let vm_context = result_object.instance.generate_context(); + // We group the calls together + l98_assert_return_invoke(&result_object, &vm_context); + l99_assert_return_invoke(&result_object, &vm_context); + l100_assert_return_invoke(&result_object, &vm_context); + l101_assert_return_invoke(&result_object, &vm_context); + l103_assert_return_invoke(&result_object, &vm_context); + l104_assert_return_invoke(&result_object, &vm_context); + l105_assert_return_invoke(&result_object, &vm_context); + l106_assert_return_invoke(&result_object, &vm_context); + l109_assert_return_invoke(&result_object, &vm_context); + l115_assert_return_invoke(&result_object, &vm_context); + l122_assert_return_invoke(&result_object, &vm_context); +}