Extend StaticComparison w/ support of === operator

This commit is contained in:
Sijawusz Pur Rahnama 2022-11-01 03:35:20 +01:00
parent 849be52618
commit ea42911c3c
2 changed files with 17 additions and 9 deletions

View file

@ -6,13 +6,21 @@ module Ameba::Rule::Lint
describe StaticComparison do
it "passes for valid cases" do
expect_no_issues subject, <<-CRYSTAL
/foo/ === "foo"
"foo" == foo
"foo" != foo
foo == "foo"
foo != "foo"
CRYSTAL
end
it "reports if there is a static comparison evaluating to true" do
it "reports if there is a static comparison evaluating to the same" do
expect_issue subject, <<-CRYSTAL
"foo" === "foo"
# ^^^^^^^^^^^^^ error: Comparison always evaluates to the same
CRYSTAL
end
it "reports if there is a static comparison evaluating to true (2)" do
expect_issue subject, <<-CRYSTAL
"foo" == "foo"
# ^^^^^^^^^^^^ error: Comparison always evaluates to true