Skip to content

Commit 5c0791f

Browse files
committed
Add a spec for emitting warning for duplicated when clauses
1 parent 78d3f39 commit 5c0791f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spec/ruby/language/case_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,19 @@ def test(v)
415415
self.test("bar").should == false
416416
self.test(true).should == true
417417
end
418+
419+
it "warns if there are identical when clauses" do
420+
-> {
421+
eval <<~RUBY
422+
case 1
423+
when 2
424+
:foo
425+
when 2
426+
:bar
427+
end
428+
RUBY
429+
}.should complain(/warning: duplicated .when' clause with line \d+ is ignored/, verbose: true)
430+
end
418431
end
419432

420433
describe "The 'case'-construct with no target expression" do

0 commit comments

Comments
 (0)