public function testLastIndexOf() { // from js $numbers = array(1, 0, 1, 0, 0, 1, 0, 0, 0); $this->assertEquals(5, __u::lastIndexOf($numbers, 1), 'can computer lastIndexOf'); $this->assertEquals(8, __u::lastIndexOf($numbers, 0), 'lastIndexOf the other element'); $this->assertEquals(-1, __u::lastIndexOf(null, 2), 'handles nulls properly'); $func = function () { return __u::lastIndexOf(func_get_args(), 1); }; $result = $func(1, 0, 1, 0, 0, 1, 0, 0, 0); $this->assertEquals(5, $result, 'works on an arguments object'); // extra $this->assertEquals(4, __u(array('a', 'b', 'c', 'c', 'c', 'd'))->lastIndexOf('c'), 'works with OO-style calls'); $this->assertEquals('c', __u(array('a' => 5, 'b' => 10, 'c' => 10))->lastIndexOf(10), 'works with associative arrays'); $this->assertEquals(2, __u::lastIndexOf('foobar', 'o'), 'works with strings'); // docs $this->assertEquals(4, __u::lastIndexOf(array(1, 2, 3, 2, 2), 2)); }