1
use super::*;
2

            
3
#[test]
4
1
fn a_thrown_condition_wins() {
5
1
    let kept = prefer_thrown(
6
1
        wasmtime::Error::new(wasmtime::ThrownException),
7
1
        wasmtime::Error::msg("original"),
8
1
    );
9
1
    assert!(kept.is::<wasmtime::ThrownException>(), "{kept}");
10
1
}
11

            
12
#[test]
13
1
fn a_trap_while_throwing_wins_over_the_condition() {
14
1
    let kept = prefer_thrown(
15
1
        wasmtime::Error::new(wasmtime::Trap::OutOfFuel),
16
1
        wasmtime::Error::msg("original"),
17
1
    );
18
1
    assert_eq!(
19
1
        kept.downcast_ref::<wasmtime::Trap>(),
20
1
        Some(&wasmtime::Trap::OutOfFuel)
21
    );
22
1
}
23

            
24
#[test]
25
1
fn a_build_failure_falls_back_to_the_condition() {
26
1
    let kept = prefer_thrown(
27
1
        wasmtime::Error::msg("module does not export `nomi_error`"),
28
1
        wasmtime::Error::msg("original"),
29
1
    );
30
1
    assert_eq!(kept.to_string(), "original");
31
1
}