Commit f65b35dc authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Fix test for `Array#slice`

parent 6865826a
......@@ -298,11 +298,38 @@ assert('Array#size', '15.2.12.5.28') do
end
assert('Array#slice', '15.2.12.5.29') do
a = "12345".slice(1, 3)
b = a.slice(0)
assert_equal("2:", "#{b}:")
assert_equal(2, [1,2,3].[](1))
a = [*(1..100)]
b = a.dup
assert_equal(1, a.slice(0))
assert_equal(100, a.slice(99))
assert_nil(a.slice(100))
assert_equal(100, a.slice(-1))
assert_equal(99, a.slice(-2))
assert_equal(1, a.slice(-100))
assert_nil(a.slice(-101))
assert_equal([1], a.slice(0,1))
assert_equal([100], a.slice(99,1))
assert_equal([], a.slice(100,1))
assert_equal([100], a.slice(99,100))
assert_equal([100], a.slice(-1,1))
assert_equal([99], a.slice(-2,1))
assert_equal([10, 11, 12], a.slice(9, 3))
assert_equal([10, 11, 12], a.slice(-91, 3))
assert_nil(a.slice(-101, 2))
assert_equal([1], a.slice(0..0))
assert_equal([100], a.slice(99..99))
assert_equal([], a.slice(100..100))
assert_equal([100], a.slice(99..200))
assert_equal([100], a.slice(-1..-1))
assert_equal([99], a.slice(-2..-2))
assert_equal([10, 11, 12], a.slice(9..11))
assert_equal([10, 11, 12], a.slice(-91..-89))
assert_equal([10, 11, 12], a.slice(-91..-89))
assert_nil(a.slice(-101..-1))
assert_nil(a.slice(10, -3))
assert_equal([], a.slice(10..7))
assert_equal(b, a)
end
assert('Array#unshift', '15.2.12.5.30') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment