Skip to content

Commit

Permalink
Additional specs for destructuring in for loops
Browse files Browse the repository at this point in the history
The extra cases have been based on the different parse results that
Prism generates for these code snippets.
  • Loading branch information
herwinw committed Jun 15, 2024
1 parent d70c812 commit 251d07e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions language/for_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
end
end

it "iterates over a list of arrays and destructures with an empty splat" do
for i, * in [[1,2]]
i.should == 1
end
end

it "iterates over a list of arrays and destructures with a splat" do
for i, *j in [[1,2]]
i.should == 1
j.should == [2]
end
end

it "iterates over a liestof arrays and destructures with a splat and additional targets" do
for i, *j, k in [[1,2]]
i.should == 1
j.should == []
k.should == 2
end
end

it "iterates over an Hash passing each key-value pair to the block" do
k = 0
l = 0
Expand Down

0 comments on commit 251d07e

Please sign in to comment.