Files
wasmtime/crates/api/tests/name.rs
Alex Crichton 2b7d627007 Remove HostRef as a reexport from wasmtime (#794)
This continues #788 and literally removes the type from the public API
of the `wasmtime` crate, making it inaccessible to the outside world.
Now it's purely an implementation detail, yay!
2020-01-10 14:36:31 -06:00

39 lines
836 B
Rust

use wasmtime::*;
#[test]
fn test_module_no_name() -> anyhow::Result<()> {
let store = Store::default();
let binary = wat::parse_str(
r#"
(module
(func (export "run") (nop))
)
"#,
)?;
let module = Module::new(&store, &binary)?;
assert_eq!(module.name(), None);
Ok(())
}
#[test]
fn test_module_name() -> anyhow::Result<()> {
let store = Store::default();
let binary = wat::parse_str(
r#"
(module $from_name_section
(func (export "run") (nop))
)
"#,
)?;
let module = Module::new(&store, &binary)?;
assert_eq!(module.name(), Some("from_name_section"));
let module = Module::new_with_name(&store, &binary, "override")?;
assert_eq!(module.name(), Some("override"));
Ok(())
}