diff options
| author | take_cheeze <[email protected]> | 2014-05-02 23:20:48 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2014-05-02 23:20:48 +0900 |
| commit | 44dc05f12a06e329119b6bf5606e4836b653c48f (patch) | |
| tree | 1dcf10c618c387c61d956e75e5e017495b7ce6d2 /mrbgems/mruby-array-ext/test | |
| parent | d91c9a9ea41349b2455ed89e4fbd46de0374c53b (diff) | |
| download | mruby-44dc05f12a06e329119b6bf5606e4836b653c48f.tar.gz mruby-44dc05f12a06e329119b6bf5606e4836b653c48f.zip | |
Implement Struct#values_at and Array#values_at .
Add API `mrb_get_values_at()` to mruby/range.h .
Diffstat (limited to 'mrbgems/mruby-array-ext/test')
| -rw-r--r-- | mrbgems/mruby-array-ext/test/array.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb index b0ad94b38..1fa7cfc04 100644 --- a/mrbgems/mruby-array-ext/test/array.rb +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -280,3 +280,13 @@ assert("Array#select!") do assert_equal [4, 5], a.select! { |val| val > 3 } assert_equal [4, 5], a end + +assert('Array#values_at') do + a = %w{red green purple white none} + + assert_equal %w{red purple none}, a.values_at(0, 2, 4) + assert_equal ['green', 'white', nil, nil], a.values_at(1, 3, 5, 7) + assert_equal ['none', 'white', 'white', nil], a.values_at(-1, -2, -2, -7) + assert_equal ['none', nil, nil, 'red', 'green', 'purple'], a.values_at(4..6, 0...3) + assert_raise(TypeError) { a.values_at 'tt' } +end |
