Skip to content

Commit

Permalink
Add additional test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jan 24, 2025
1 parent 0b50b1d commit 389c5a1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/ameba/rule/lint/useless_assign_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,18 @@ module Ameba::Rule::Lint
CRYSTAL
end

it "reports if it's not referenced at a top level + in a method" do
expect_issue subject, <<-CRYSTAL
a : String?
# ^{} error: Useless assignment to variable `a`
def foo
b : String?
# ^ error: Useless assignment to variable `b`
end
CRYSTAL
end

it "reports if it's not referenced in a method" do
expect_issue subject, <<-CRYSTAL
def foo
Expand Down Expand Up @@ -1078,6 +1090,18 @@ module Ameba::Rule::Lint
CRYSTAL
end

it "reports if uninitialized assignment is not referenced at a top level + in a method" do
expect_issue subject, <<-CRYSTAL
a = uninitialized U
# ^{} error: Useless assignment to variable `a`
def foo
b = uninitialized U
# ^ error: Useless assignment to variable `b`
end
CRYSTAL
end

it "reports if uninitialized assignment is not referenced in a method" do
expect_issue subject, <<-CRYSTAL
def foo
Expand Down

0 comments on commit 389c5a1

Please sign in to comment.