public function testSlice()
 {
     $this->eq(s::slice('abcdef', 1, 3), 'bc');
     $this->eq(s::slice('abcdef', 3, 4), 'd');
     $this->eq(s::slice('abcdef', 3, 3), '');
     $this->eq(s::slice('abcdef', 3, 2), '');
     $this->eq(s::slice('abcdef', 2), 'cdef');
     $this->eq(s::slice('abcdef', 2, 1000), 'cdef');
     $this->eq(s::slice('abcdef', 1000), '');
     $this->eq(s::slice('abcdef', 1000, 4), '');
     $this->eq(s::slice('abcdef', 1000, 2000), '');
     $this->eq(s::slice('abcdef', 0, -2), 'abcd');
     $this->eq(s::slice('abcdef', 1, -1), 'bcde');
     $this->eq(s::slice('abcdef', 3, -3), '');
     $this->eq(s::slice('abcdef', 4, -5), '');
     $this->eq(s::slice('abcdef', -4, -2), 'cd');
     $this->eq(s::slice('abcdef', -4, 4), 'cd');
     $this->eq(s::slice('abcdef', -1000), 'abcdef');
     $this->eq(s::slice('abcdef', -1000, -2), 'abcd');
     $this->eq(s::slice('abcdef', -1000, -100), '');
     $this->eq(s::slice('', 3, 5), '');
 }
Exemple #2
0
 public function slice($i, $j = null)
 {
     return new self(s::slice($this->value, $i, $j));
 }