#![cfg(not(miri))]
use wasmtime::*;
#[test]
fn code_too_large_without_panic() -> Result<()> {
const N: usize = 120000;
let mut s = String::new();
s.push_str("(module\n");
s.push_str("(table 1 1 funcref)\n");
s.push_str("(func (export \"\") (result i32)\n");
s.push_str("i32.const 0\n");
for _ in 0..N {
s.push_str("table.get 0\n");
s.push_str("ref.is_null\n");
}
s.push_str("))\n");
let store = Store::<()>::default();
let result = Module::new(store.engine(), &s);
match result {
Err(e) => assert!(e
.to_string()
.starts_with("Compilation error: Code for function is too large")),
Ok(_) => panic!("Please adjust limits to make the module too large to compile!"),
}
Ok(())
}