Refactor Lint/StaticComparison to LiteralsComparison

This commit is contained in:
Sijawusz Pur Rahnama 2022-11-02 01:39:10 +01:00
parent 23ca87ff0e
commit 6bf8db81e3
2 changed files with 35 additions and 12 deletions

View file

@ -1,9 +1,9 @@
require "../../../spec_helper"
module Ameba::Rule::Lint
subject = StaticComparison.new
subject = LiteralsComparison.new
describe StaticComparison do
describe LiteralsComparison do
it "passes for valid cases" do
expect_no_issues subject, <<-CRYSTAL
"foo" == foo
@ -13,6 +13,13 @@ module Ameba::Rule::Lint
CRYSTAL
end
it "reports if there is a regex comparison possibly evaluating to the same" do
expect_issue subject, <<-CRYSTAL
/foo/ === "foo"
# ^^^^^^^^^^^^^ error: Comparison most likely evaluates to the same
CRYSTAL
end
it "reports if there is a static comparison evaluating to the same" do
expect_issue subject, <<-CRYSTAL
"foo" === "foo"