You've already forked wit-bindgen
mirror of
https://github.com/AdaCore/wit-bindgen.git
synced 2026-02-12 13:12:42 -08:00
* Update Rust codegen for new WIT changes * Update the markdown generation for new WIT * more-rust * Update the C generator for new WIT * Get Rust guest tests compiling * Get rust host tests working * Get all C tests passing * Turn off teavm-java and Go tests for now * Fixup lockfile after rebase * Bump crate versions * Update dependency sources * Update to wasmtime dep
40 lines
1.0 KiB
Rust
40 lines
1.0 KiB
Rust
use anyhow::Result;
|
|
use wasmtime::Store;
|
|
|
|
wasmtime::component::bindgen!(in "tests/runtime/strings");
|
|
|
|
#[derive(Default)]
|
|
pub struct MyImports;
|
|
|
|
impl test::strings::imports::Host for MyImports {
|
|
fn take_basic(&mut self, s: String) -> Result<()> {
|
|
assert_eq!(s, "latin utf16");
|
|
Ok(())
|
|
}
|
|
|
|
fn return_unicode(&mut self) -> Result<String> {
|
|
Ok("🚀🚀🚀 𠈄𓀀".to_string())
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn run() -> Result<()> {
|
|
crate::run_test(
|
|
"strings",
|
|
|linker| Strings::add_to_linker(linker, |x| &mut x.0),
|
|
|store, component, linker| Strings::instantiate(store, component, linker),
|
|
run_test,
|
|
)
|
|
}
|
|
|
|
fn run_test(exports: Strings, store: &mut Store<crate::Wasi<MyImports>>) -> Result<()> {
|
|
exports.call_test_imports(&mut *store)?;
|
|
assert_eq!(exports.call_return_empty(&mut *store)?, "");
|
|
assert_eq!(exports.call_roundtrip(&mut *store, "str")?, "str");
|
|
assert_eq!(
|
|
exports.call_roundtrip(&mut *store, "🚀🚀🚀 𠈄𓀀")?,
|
|
"🚀🚀🚀 𠈄𓀀"
|
|
);
|
|
Ok(())
|
|
}
|