Fail with Trap in Instance::new() instead of Error (#683)

This commit is contained in:
Yury Delendik
2019-12-30 16:25:16 -06:00
committed by GitHub
parent 51f3ac0c45
commit 681445b18b
18 changed files with 172 additions and 86 deletions

View File

@@ -20,7 +20,7 @@ fn test_import_calling_export() {
}
impl Callable for Callback {
fn call(&self, _params: &[Val], _results: &mut [Val]) -> Result<(), HostRef<Trap>> {
fn call(&self, _params: &[Val], _results: &mut [Val]) -> Result<(), Trap> {
self.other
.borrow()
.as_ref()

View File

@@ -7,8 +7,8 @@ fn test_trap_return() -> Result<(), String> {
struct HelloCallback;
impl Callable for HelloCallback {
fn call(&self, _params: &[Val], _results: &mut [Val]) -> Result<(), HostRef<Trap>> {
Err(HostRef::new(Trap::new("test 123")))
fn call(&self, _params: &[Val], _results: &mut [Val]) -> Result<(), Trap> {
Err(Trap::new("test 123"))
}
}
@@ -32,7 +32,7 @@ fn test_trap_return() -> Result<(), String> {
let imports = vec![hello_func.into()];
let instance = Instance::new(&store, &module, imports.as_slice())
.map_err(|e| format!("failed to instantiate module: {}", e))?;
.map_err(|e| format!("failed to instantiate module: {:?}", e))?;
let run_func = instance.exports()[0]
.func()
.expect("expected function export");
@@ -43,7 +43,7 @@ fn test_trap_return() -> Result<(), String> {
.err()
.expect("error calling function");
assert_eq!(e.borrow().message(), "test 123");
assert_eq!(e.message(), "test 123");
Ok(())
}