message: test: add test for invalid initialiser in element and data sections
diff: @@ -874,6 +874,14 @@ TEST(parser, element_section_tableidx_nonzero)
  EXPECT_THROW_MESSAGE(parse(bin), parser_error, "unexpected tableidx value 1");
  }
  +TEST(parser, element_section_invalid_initializer)
  +{
  + // tableidx=0 expression=<memory_size> items=0
  + const auto wasm = bytes{wasm_prefix} + make_section(9, make_vec({"003f00"_bytes}));
  + EXPECT_THROW_MESSAGE(
  + parse(wasm), validation_error, "unexpected instruction in the constant expression: 63");
  +}
  +
  TEST(parser, element_section_no_table_section)
  {
  const auto wasm =
  @@ -1247,6 +1255,14 @@ TEST(parser, data_section_memidx_nonzero)
  EXPECT_THROW_MESSAGE(parse(bin), parser_error, "unexpected memidx value 1");
  }
  +TEST(parser, data_section_invalid_initializer)
  +{
  + // memidx=0 expression=<memory_size> items=0
  + const auto wasm = bytes{wasm_prefix} + make_section(9, make_vec({"003f00"_bytes}));
  + EXPECT_THROW_MESSAGE(
  + parse(wasm), validation_error, "unexpected instruction in the constant expression: 63");
  +}
  +
  TEST(parser, data_section_empty_vector_without_memory)
  {
  const auto bin = bytes{wasm_prefix} + make_section(11, make_vec({"0041010b00"_bytes}));
  