public function testRange() { // Act $x = __::range(5); $y = __::range(-2, 2); $z = __::range(1, 10, 2); // Assert $this->assertEquals([1, 2, 3, 4, 5], $x); $this->assertEquals([-2, -1, 0, 1, 2], $y); $this->assertEquals([1, 3, 5, 7, 9], $z); }
public function testRange() { // from js $this->assertEquals(array(), __::range(0), 'range with 0 as a first argument generates an empty array'); $this->assertEquals(array(0, 1, 2, 3), __::range(4), 'range with a single positive argument generates an array of elements 0,1,2,...,n-1'); $this->assertEquals(array(5, 6, 7), __::range(5, 8), 'range with two arguments a & b, a<b generates an array of elements a,a+1,a+2,...,b-2,b-1'); $this->assertEquals(array(), __::range(8, 5), 'range with two arguments a & b, b<a generates an empty array'); $this->assertEquals(array(3, 6, 9), __::range(3, 10, 3), 'range with three arguments a & b & c, c < b-a, a < b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) < c'); $this->assertEquals(array(3), __::range(3, 10, 15), 'range with three arguments a & b & c, c > b-a, a < b generates an array with a single element, equal to a'); $this->assertEquals(array(12, 10, 8), __::range(12, 7, -2), 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b'); $this->assertEquals(array(0, -1, -2, -3, -4, -5, -6, -7, -8, -9), __::range(0, -10, -1), 'final example in the Python docs'); // extra $this->assertEquals(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), __::range(10)); $this->assertEquals(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), __::range(1, 11)); $this->assertEquals(array(0, 5, 10, 15, 20, 25), __::range(0, 30, 5)); $this->assertEquals(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), __(10)->range(), 'works in OO-style calls and 1 parameter'); $this->assertEquals(array(10, 11, 12), __(10)->range(13), 'works in OO-style calls and 2 parameters'); $this->assertEquals(array(3, 6, 9), __(3)->range(10, 3), 'works in OO-style calls and 3 parameters'); // docs $this->assertEquals(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), __::range(10)); $this->assertEquals(array(1, 2, 3, 4), __::range(1, 5)); $this->assertEquals(array(0, 5, 10, 15, 20, 25), __::range(0, 30, 5)); $this->assertEquals(array(0, -1, -2, -3, -4), __::range(0, -5, -1)); $this->assertEquals(array(), __::range(0)); }
public function testRange() { $return = array(0, 5, 10, 15); $result = __::range(0, 20, 5); $this->assertEquals($return, $result); }
public function testShuffle() { // from js $numbers = __::range(10); $shuffled = __::shuffle($numbers); sort($shuffled); $this->assertEquals(join(',', $numbers), join(',', $shuffled), 'contains the same members before and after shuffle'); }