use javascript::{Value, evaluate_script};
#[ctor::ctor]
fn __init_test_logger() {
let _ = env_logger::Builder::from_env(env_logger::Env::default()).is_test(true).try_init();
}
#[test]
fn bigint_global_and_prototype_to_string_value_of() {
let r1 = evaluate_script("BigInt('123')", None::<&std::path::Path>);
match r1 {
Ok(Value::BigInt(h)) => assert_eq!(h.to_string(), "123"),
other => panic!("expected BigInt result for BigInt('123'), got {:?}", other),
}
let r2 = evaluate_script("BigInt(42)", None::<&std::path::Path>);
match r2 {
Ok(Value::BigInt(h)) => assert_eq!(h.to_string(), "42"),
other => panic!("expected BigInt result for BigInt(42), got {:?}", other),
}
let r3 = evaluate_script("String(123n)", None::<&std::path::Path>);
match r3 {
Ok(Value::String(s)) => assert_eq!(String::from_utf16_lossy(&s), "123"),
other => panic!("expected string result for String(123n), got {:?}", other),
}
let r4 = evaluate_script("BigInt(7) === 7n", None::<&std::path::Path>);
match r4 {
Ok(Value::Boolean(b)) => assert!(b),
other => panic!("expected boolean result for BigInt(7) === 7n, got {:?}", other),
}
let r5 = evaluate_script("Object(123n).toString()", None::<&std::path::Path>);
match r5 {
Ok(Value::String(s)) => assert_eq!(String::from_utf16_lossy(&s), "123"),
other => panic!("expected string result for Object(123n).toString(), got {:?}", other),
}
let r6 = evaluate_script("Object(7n).valueOf() === 7n", None::<&std::path::Path>);
match r6 {
Ok(Value::Boolean(b)) => assert!(b),
other => panic!("expected boolean result for Object(7n).valueOf() === 7n, got {:?}", other),
}
}