add usage test

This commit is contained in:
Folkert 2020-07-20 14:06:31 +02:00
parent 8eb287dfab
commit eed8ff38e6

View file

@ -765,4 +765,30 @@ mod test_usage_analysis {
},
);
}
#[test]
fn record_pattern_optional_fields() {
usage_eq(
indoc!(
r#"
a = 34
when r is
{ x, y ? a, z ? a } -> x + y + z
"#
),
|interns| {
let mut usage = VarUsage::default();
let home = test_home();
usage.register_with(interns.symbol(home, "a".into()), &Simple(Shared));
usage.register_with(interns.symbol(home, "x".into()), &Simple(Seen));
usage.register_with(interns.symbol(home, "y".into()), &Simple(Seen));
usage.register_with(interns.symbol(home, "z".into()), &Simple(Seen));
usage.register_shared(Symbol::NUM_ADD);
usage
},
);
}
}