From 69f9e121fb654ad5bb23cbcbef648f5ab4aefee0 Mon Sep 17 00:00:00 2001 From: "Shahar \"Dawn\" Or" Date: Sat, 30 Aug 2025 16:40:53 +0700 Subject: [PATCH] test(bool_comparison): has attr cases Co-authored-by: x10an14 --- bin/tests/data/bool_comparison.nix | 4 ++++ bin/tests/snapshots/main__bool_comparison_fix.snap | 8 +++++++- .../snapshots/main__bool_comparison_lint.snap | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/tests/data/bool_comparison.nix b/bin/tests/data/bool_comparison.nix index 00a1284..28b3b1e 100644 --- a/bin/tests/data/bool_comparison.nix +++ b/bin/tests/data/bool_comparison.nix @@ -20,4 +20,8 @@ (false == true) (true == false) (true == true) + + # has attr + (false == m ? n) + (true == o ? p) ] diff --git a/bin/tests/snapshots/main__bool_comparison_fix.snap b/bin/tests/snapshots/main__bool_comparison_fix.snap index 1f5c041..614e9af 100644 --- a/bin/tests/snapshots/main__bool_comparison_fix.snap +++ b/bin/tests/snapshots/main__bool_comparison_fix.snap @@ -4,7 +4,7 @@ expression: "& stdout" --- --- tests/data/bool_comparison.nix +++ tests/data/bool_comparison.nix [fixed] -@@ -1,23 +1,23 @@ +@@ -1,27 +1,27 @@ [ # trivial - (a == true) @@ -39,4 +39,10 @@ expression: "& stdout" + (!true) + false + true + + # has attr +- (false == m ? n) +- (true == o ? p) ++ (!m ? n) ++ (o ? p) ] diff --git a/bin/tests/snapshots/main__bool_comparison_lint.snap b/bin/tests/snapshots/main__bool_comparison_lint.snap index cd8ced2..7b8a5aa 100644 --- a/bin/tests/snapshots/main__bool_comparison_lint.snap +++ b/bin/tests/snapshots/main__bool_comparison_lint.snap @@ -86,3 +86,17 @@ expression: "& out" · ──────┬───── · ╰─────── Comparing true with boolean literal true ────╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:25:4] + │ + 25 │ (false == m ? n) + · ───────┬────── + · ╰──────── Comparing m ? n with boolean literal false +────╯ +[W01] Warning: Unnecessary comparison with boolean + ╭─[data/bool_comparison.nix:26:4] + │ + 26 │ (true == o ? p) + · ──────┬────── + · ╰──────── Comparing o ? p with boolean literal true +────╯ -- 2.51.2