From 591b3c76e4a79d0580345e47b99c2d90a4a479d8 Mon Sep 17 00:00:00 2001 From: alexion Date: Sat, 26 Sep 2026 19:55:27 -0400 Subject: [PATCH] test(xatu): cover nested let ordering --- src/xatu/testdata/lint_findings.nix | 9 ++++++++- src/xatu/xatu_test.rs | 16 +++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/xatu/testdata/lint_findings.nix b/src/xatu/testdata/lint_findings.nix index d4f174c..a4eb0d8 100644 --- a/src/xatu/testdata/lint_findings.nix +++ b/src/xatu/testdata/lint_findings.nix @@ -1,10 +1,17 @@ let - second = 2; + second = first; first = 1; + nested = let + nestedFirst = first; + nestedSecond = nestedFirst; + in { + result = nestedSecond; + }; in { package = package; from = pkgs.from; url = https://example.com; firstField = first; secondField = second; + nestedField = nested; } diff --git a/src/xatu/xatu_test.rs b/src/xatu/xatu_test.rs index a2c033c..66ebd71 100644 --- a/src/xatu/xatu_test.rs +++ b/src/xatu/xatu_test.rs @@ -42,17 +42,15 @@ fn xatu_rejects_invalid_source() -> googletest::Result<()> { } #[gtest] -fn xatu_reports_out_of_order_let_binding() -> googletest::Result<()> { +fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> { let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?; - expect_that!( - report - .diagnostics - .iter() - .map(|diagnostic| diagnostic.finding.rule_id) - .collect::>(), - contains(eq(&"let_order")) - ); + let let_order_count = report + .diagnostics + .iter() + .filter(|diagnostic| diagnostic.finding.rule_id == "let_order") + .count(); + expect_that!(let_order_count, eq(4)); Ok(()) }