summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-04-27 16:37:24 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-04-27 16:37:24 +0900
commit9f77232b71597dbef3907ae4aaae1a5530889e56 (patch)
tree4e11cd1ac6a5d5e06190c0dc6883c6bef32aa06a /test
parent2e165b9e2013d68d3d2093b6e14414382405dedf (diff)
downloadmruby-9f77232b71597dbef3907ae4aaae1a5530889e56.tar.gz
mruby-9f77232b71597dbef3907ae4aaae1a5530889e56.zip
array.c: update `Array#shift` to take optional argument; close #5428
Diffstat (limited to 'test')
-rw-r--r--test/t/array.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/t/array.rb b/test/t/array.rb
index 7410233d3..5f26259f2 100644
--- a/test/t/array.rb
+++ b/test/t/array.rb
@@ -295,6 +295,24 @@ assert('Array#shift', '15.2.12.5.27') do
assert_equal(1, b)
assert_raise(FrozenError) { [].freeze.shift }
+
+ # Array#shift with argument
+ assert_equal([], [].shift(1))
+
+ a = [1,2,3]
+ b = a.shift(1)
+ assert_equal([2,3], a)
+ assert_equal([1], b)
+
+ a = [1,2,3,4]
+ b = a.shift(3)
+ assert_equal([4], a)
+ assert_equal([1,2,3], b)
+
+ a = [1,2,3]
+ b = a.shift(4)
+ assert_equal([], a)
+ assert_equal([1,2,3], b)
end
assert('Array#size', '15.2.12.5.28') do