Skip to content

Commit

Permalink
Array#permutation: Test that the enum doesn't cache anything about th…
Browse files Browse the repository at this point in the history
…e array.
  • Loading branch information
marcandre committed Dec 31, 2009
1 parent d485b7e commit eedf133
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/array/permutation_spec.rb
Expand Up @@ -87,6 +87,14 @@
@numbers.permutation(3.7).to_a.sort.should ==
@numbers.permutation(3).to_a.sort
end


it "returns an Enumerator which works as expected even when the array was modified" do
@numbers = [1, 2]
enum = @numbers.permutation
@numbers << 3
enum.to_a.sort.should == [
[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]
].sort
end
end
end

0 comments on commit eedf133

Please sign in to comment.