Skip to content

Commit

Permalink
Test - Moved without()
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhaveri committed May 22, 2011
1 parent 6fc7961 commit cd85afb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
19 changes: 19 additions & 0 deletions test/ArraysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,23 @@ public function testFlatten() {
equals(result.join(', '), '1, 2, 3, 4', 'works on an arguments object');
*/
}

public function testWithout() {
$list = array(1, 2, 1, 0, 3, 1, 4);

// from js
$this->assertEquals(array(1=>2,4=>3,6=>4), _::without($list, 0, 1), 'can remove all instances of an object');
$list = array(
(object) array('one'=>1),
(object) array('two'=>2)
);
$this->assertEquals(2, count(_::without($list, (object) array('one'=>1))), 'uses real object identity for comparisons.');
$this->assertEquals(1, count(_::without($list, $list[0])), 'ditto.');

// @todo
/*
var result = (function(){ return _.without(arguments, 0, 1); })(1, 2, 1, 0, 3, 1, 4);
equals(result.join(', '), '2, 3, 4', 'works on an arguments object');
*/
}
}
11 changes: 0 additions & 11 deletions underscore-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,6 @@ public function testSize() {
}
}

public function testWithout() {
$tests = array(
// val, expected
array(array(0, 1, 2), array(0, 2=>2)),
array(array(true, false, 0, 1, 2, '1'), array(1=>false, 2=>0, 4=>2))
);
foreach($tests as $test) {
$this->assertEquals($test[1], _::without($test[0], 1, '1', true));
}
}

public function testUniq() {
$tests = array(
// val, expected
Expand Down

0 comments on commit cd85afb

Please sign in to comment.