From eed8ff38e68c78188cc94e539969746de6488746 Mon Sep 17 00:00:00 2001 From: Folkert Date: Mon, 20 Jul 2020 14:06:31 +0200 Subject: [PATCH] add usage test --- compiler/uniq/tests/test_usage_analysis.rs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/compiler/uniq/tests/test_usage_analysis.rs b/compiler/uniq/tests/test_usage_analysis.rs index d7add10545..c33dffc776 100644 --- a/compiler/uniq/tests/test_usage_analysis.rs +++ b/compiler/uniq/tests/test_usage_analysis.rs @@ -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 + }, + ); + } }