Lines
100 %
Functions
60 %
Branches
use wasmtime::{AnyRef, Config, Engine, I31, Store};
use super::CheckedAnyRef;
fn gc_store() -> wasmtime::Result<Store<()>> {
let mut config = Config::new();
config.wasm_gc(true);
config.wasm_function_references(true);
Ok(Store::new(&Engine::new(&config)?, ()))
}
#[test]
fn checked_i31_reads_an_i31_ref() -> wasmtime::Result<()> {
let mut store = gc_store()?;
let value = I31::new_i32(7).ok_or_else(|| wasmtime::Error::msg("7 fits in i31"))?;
let any = AnyRef::from_i31(&mut store, value);
assert_eq!(any.checked_i31(&store)?.get_i32(), 7);
Ok(())
fn checked_struct_and_array_reject_an_i31_ref_without_panicking() -> wasmtime::Result<()> {
assert!(any.checked_struct(&store).is_err());
assert!(any.checked_array(&store).is_err());