Skip to content

Commit

Permalink
Fix incorrect results from Array#intersect. [#841 state:resolved] (…
Browse files Browse the repository at this point in the history
…Alexey Bass, Yaffle, Victor)
  • Loading branch information
savetheclocktower committed Mar 4, 2012
1 parent eac97a0 commit 191f458
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/prototype/lang/array.js
Expand Up @@ -358,7 +358,7 @@ Array.from = $A;
**/
function intersect(array) {
return this.uniq().findAll(function(item) {
return array.detect(function(value) { return item === value });
return array.indexOf(item) !== -1;
});
}

Expand Down
1 change: 1 addition & 0 deletions test/unit/array_test.js
Expand Up @@ -131,6 +131,7 @@ new Test.Unit.Runner({

testIntersect: function(){
this.assertEnumEqual([1,3], [1,1,3,5].intersect([1,2,3]));
this.assertEnumEqual([0,1], [0,1,2].intersect([0,1]));
this.assertEnumEqual([1], [1,1].intersect([1,1]));
this.assertEnumEqual([], [1,1,3,5].intersect([4]));
this.assertEnumEqual([], [1].intersect(['1']));
Expand Down

0 comments on commit 191f458

Please sign in to comment.