diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-30 08:29:20 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-30 08:29:20 +0900 |
| commit | ebb29f04502485f634cad6ca649c7c3ff12182f9 (patch) | |
| tree | 3ffbde944d2356f64b1435a9c74c23ef553d19e9 /mrbgems/mruby-array-ext/test/array.rb | |
| parent | 2277c374db6c4ca1793911381ee5e323081c439d (diff) | |
| parent | 8cdac8221dafbf23fca898afb4249e5fc0a163c6 (diff) | |
| download | mruby-ebb29f04502485f634cad6ca649c7c3ff12182f9.tar.gz mruby-ebb29f04502485f634cad6ca649c7c3ff12182f9.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'mrbgems/mruby-array-ext/test/array.rb')
| -rw-r--r-- | mrbgems/mruby-array-ext/test/array.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb index ab830cca7..7f296f591 100644 --- a/mrbgems/mruby-array-ext/test/array.rb +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -118,3 +118,16 @@ assert("Array#fetch") do assert_equal 100, ret assert_raise(IndexError) { a.fetch(100) } end + +assert("Array#fill") do + a = [ "a", "b", "c", "d" ] + assert_equal ["x", "x", "x", "x"], a.fill("x") + assert_equal ["x", "x", "x", "w"], a.fill("w", -1) + assert_equal ["x", "x", "z", "z"], a.fill("z", 2, 2) + assert_equal ["y", "y", "z", "z"], a.fill("y", 0..1) + assert_equal [0, 1, 4, 9], a.fill { |i| i*i } + assert_equal [0, 1, 8, 27], a.fill(-2) { |i| i*i*i } + assert_equal [0, 2, 3, 27], a.fill(1, 2) { |i| i+1 } + assert_equal [1, 2, 3, 27], a.fill(0..1) { |i| i+1 } + assert_raise(ArgumentError) { a.fill } +end |
