@@ -743,6 +743,30 @@ def to.to_int() -2 end
743743        @array . send ( @method ,  eval ( "(-2..-4).step(10)" ) ) . should  == [ ] 
744744        @array . send ( @method ,  eval ( "(-2...-4).step(10)" ) ) . should  == [ ] 
745745      end 
746+ 
747+       it  "has range with bounds outside of array"  do 
748+         # end is equal to array's length 
749+         @array . send ( @method ,  ( 0 ..6 ) . step ( 1 ) ) . should  == [ 0 ,  1 ,  2 ,  3 ,  4 ,  5 ] 
750+         ->  {  @array . send ( @method ,  ( 0 ..6 ) . step ( 2 ) )  } . should  raise_error ( RangeError ) 
751+ 
752+         # end is greater than length with positive steps 
753+         @array . send ( @method ,  ( 1 ..6 ) . step ( 2 ) ) . should  == [ 1 ,  3 ,  5 ] 
754+         @array . send ( @method ,  ( 2 ..7 ) . step ( 2 ) ) . should  == [ 2 ,  4 ] 
755+         ->  {  @array . send ( @method ,  ( 2 ..8 ) . step ( 2 ) )  } . should  raise_error ( RangeError ) 
756+ 
757+         # begin is greater than length with negative steps 
758+         @array . send ( @method ,  ( 6 ..1 ) . step ( -2 ) ) . should  == [ 5 ,  3 ,  1 ] 
759+         @array . send ( @method ,  ( 7 ..2 ) . step ( -2 ) ) . should  == [ 5 ,  3 ] 
760+         ->  {  @array . send ( @method ,  ( 8 ..2 ) . step ( -2 ) )  } . should  raise_error ( RangeError ) 
761+       end 
762+ 
763+       it  "has endless range with start outside of array's bounds"  do 
764+         @array . send ( @method ,  eval ( "(6..).step(1)" ) ) . should  == [ ] 
765+         @array . send ( @method ,  eval ( "(7..).step(1)" ) ) . should  == nil 
766+ 
767+         @array . send ( @method ,  eval ( "(6..).step(2)" ) ) . should  == [ ] 
768+         ->  {  @array . send ( @method ,  eval ( "(7..).step(2)" ) )  } . should  raise_error ( RangeError ) 
769+       end 
746770    end 
747771  end 
748772
0 commit comments