summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-array-ext/test
diff options
context:
space:
mode:
authorKenji Okimoto <[email protected]>2017-03-28 14:35:34 +0900
committerKenji Okimoto <[email protected]>2017-03-28 15:07:57 +0900
commit33f77fe3670b7a7c4ac8977d13d10256b58e862e (patch)
tree11734f12310377bf447a59a2b0b56236516b6554 /mrbgems/mruby-array-ext/test
parent66980493ae2f4d587a4a45b6b1061f46c01e34be (diff)
downloadmruby-33f77fe3670b7a7c4ac8977d13d10256b58e862e.tar.gz
mruby-33f77fe3670b7a7c4ac8977d13d10256b58e862e.zip
Implement Array#slice!
Diffstat (limited to 'mrbgems/mruby-array-ext/test')
-rw-r--r--mrbgems/mruby-array-ext/test/array.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb
index 09ec8d9e7..95a796cf9 100644
--- a/mrbgems/mruby-array-ext/test/array.rb
+++ b/mrbgems/mruby-array-ext/test/array.rb
@@ -328,3 +328,27 @@ assert("Array#dig") do
assert_nil(h.dig(2, 0))
assert_raise(TypeError) {h.dig(:a)}
end
+
+assert("Array#slice!") do
+ a = [1, 2, 3]
+ b = a.slice!(0)
+ c = [1, 2, 3, 4, 5]
+ d = c.slice!(0, 2)
+ e = [1, 2, 3, 4, 5]
+ f = e.slice!(1..3)
+ g = [1, 2, 3]
+ h = g.slice!(-1)
+ i = [1, 2, 3]
+ j = i.slice!(0, -1)
+
+ assert_equal(a, [2, 3])
+ assert_equal(b, 1)
+ assert_equal(c, [3, 4, 5])
+ assert_equal(d, [1, 2])
+ assert_equal(e, [1, 5])
+ assert_equal(f, [2, 3, 4])
+ assert_equal(g, [1, 2])
+ assert_equal(h, 3)
+ assert_equal(i, [1, 2, 3])
+ assert_equal(j, nil)
+end