use hocon::{ParseOptions, ResolveOptions};
#[test]
fn both_resolved_preserves_existing_semantics() {
let a = hocon::parse(r#"a = 1"#).unwrap();
let b = hocon::parse(
r#"a = 99
c = 3"#,
)
.unwrap();
let m = a.with_fallback(&b);
assert!(m.is_resolved());
assert_eq!(m.get_i64("a").unwrap(), 1);
assert_eq!(m.get_i64("c").unwrap(), 3);
}
#[test]
fn unresolved_receiver_result_is_unresolved() {
let r = hocon::parse_string_with_options(
r#"a = ${b}"#,
ParseOptions::defaults().with_resolve_substitutions(false),
)
.unwrap();
let f = hocon::parse(r#"b = 7"#).unwrap();
let m = r.with_fallback(&f);
assert!(!m.is_resolved());
}
#[test]
fn object_merge_recursive() {
let a = hocon::parse_string_with_options(
r#"a { x = 1 }"#,
ParseOptions::defaults().with_resolve_substitutions(false),
)
.unwrap();
let b = hocon::parse_string_with_options(
r#"a { y = 2 }"#,
ParseOptions::defaults().with_resolve_substitutions(false),
)
.unwrap();
let m = a.with_fallback(&b);
assert!(m.is_resolved());
assert_eq!(m.get_i64("a.x").unwrap(), 1);
assert_eq!(m.get_i64("a.y").unwrap(), 2);
}
#[test]
fn s13a_self_ref_across_fallback() {
let r = hocon::parse_string_with_options(
r#"a = ${?a} extra"#,
ParseOptions::defaults().with_resolve_substitutions(false),
)
.unwrap();
let f = hocon::parse_string_with_options(
r#"a = base"#,
ParseOptions::defaults().with_resolve_substitutions(false),
)
.unwrap();
let merged = r.with_fallback(&f);
let resolved = merged
.resolve(ResolveOptions::defaults().with_use_system_environment(false))
.unwrap();
assert_eq!(resolved.get_string("a").unwrap(), "base extra");
}