Lots of places were assuming that bool and c int were interchangeable, but of course on windows a c int is 32 bits and that confused everybody. Tighten up the definitions in static-functions, which causes us to fix boolean conversion. Also add tests for boolean conversion, and also add better debug formatting of JS values.
31 lines
727 B
Rust
31 lines
727 B
Rust
mod into;
|
|
pub use into::*;
|
|
|
|
mod from;
|
|
pub use from::*;
|
|
|
|
mod function;
|
|
pub use function::*;
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::{Context, ContextRef, Runtime};
|
|
|
|
fn check_round_trip<T>(ctx: &ContextRef, v: T)
|
|
where
|
|
T: TryIntoValue + TryFromValue + PartialEq + Clone + std::fmt::Debug,
|
|
{
|
|
let val = v.clone().try_into_value(ctx).expect("Could not make value");
|
|
let new = T::try_from_value(&val, ctx).expect("Could not unwrap value");
|
|
assert_eq!(v, new);
|
|
}
|
|
|
|
#[test]
|
|
fn round_trip() {
|
|
let ctx = Context::new(Runtime::new());
|
|
check_round_trip(&ctx, true);
|
|
check_round_trip(&ctx, false);
|
|
check_round_trip(&ctx, 12);
|
|
}
|
|
}
|