message: test: add test for invalid global index in global initializer
diff: @@ -26,14 +26,22 @@ TEST(validation, imported_function_unknown_type)
  TEST(validation, globals_invalid_initializer)
  {
  + // initializing from non-existing global
  + /* wat2wasm --no-check
  + (global i32 (global.get 1))
  + */
  + const auto bin_invalid1 = from_hex("0061736d010000000606017f0023010b");
  + EXPECT_THROW_MESSAGE(
  + parse(bin_invalid1), validation_error, "invalid global index in constant expression");
  +
  // initializing from mutable global is not allowed
  /* wat2wasm --no-check
  (global (import "mod" "g1") (mut i32))
  (global (mut i32) (global.get 0))
  */
  - const auto bin_invalid1 =
  + const auto bin_invalid2 =
  from_hex("0061736d01000000020b01036d6f64026731037f010606017f0123000b");
  - EXPECT_THROW_MESSAGE(parse(bin_invalid1), validation_error,
  + EXPECT_THROW_MESSAGE(parse(bin_invalid2), validation_error,
  "constant expression can use global.get only for const globals");
  // initializing from non-imported global is not allowed
  @@ -41,8 +49,8 @@ TEST(validation, globals_invalid_initializer)
  (global i32 (i32.const 42))
  (global (mut i32) (global.get 0))
  */
  - const auto bin_invalid2 = from_hex("0061736d01000000060b027f00412a0b7f0123000b");
  - EXPECT_THROW_MESSAGE(parse(bin_invalid2), validation_error,
  + const auto bin_invalid3 = from_hex("0061736d01000000060b027f00412a0b7f0123000b");
  + EXPECT_THROW_MESSAGE(parse(bin_invalid3), validation_error,
  "global can be initialized by another const global only if it's imported");
  }
  