diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-28 15:24:52 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-03-28 15:24:52 +0900 |
| commit | 1bdaf9c840160b34d6cb380fe645d6fbfea0137e (patch) | |
| tree | 718582f2e6718488c9de0386ab1a557d15a7a0fa /mrbgems/mruby-array-ext/test | |
| parent | 0f5289326f1f501cc368406880244fc78d09533f (diff) | |
| parent | 33f77fe3670b7a7c4ac8977d13d10256b58e862e (diff) | |
| download | mruby-1bdaf9c840160b34d6cb380fe645d6fbfea0137e.tar.gz mruby-1bdaf9c840160b34d6cb380fe645d6fbfea0137e.zip | |
Merge pull request #3553 from okkez/add-array-slice-bang
Implement Array#slice!
Diffstat (limited to 'mrbgems/mruby-array-ext/test')
| -rw-r--r-- | mrbgems/mruby-array-ext/test/array.rb | 24 |
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 |
