summaryrefslogtreecommitdiffhomepage
path: root/mrbgems
diff options
context:
space:
mode:
authorKazuki Tsujimoto <[email protected]>2014-03-30 18:32:19 +0900
committerKazuki Tsujimoto <[email protected]>2014-03-30 18:32:19 +0900
commit01a798362f33fc6e7cd80d17dae1d87034782bbb (patch)
treeb70fd97226c00ff61378323c64e11c3c4649df2e /mrbgems
parentb1eef40630f7b97a7bef2c3f42de5ced21b05646 (diff)
downloadmruby-01a798362f33fc6e7cd80d17dae1d87034782bbb.tar.gz
mruby-01a798362f33fc6e7cd80d17dae1d87034782bbb.zip
Fix method name
Diffstat (limited to 'mrbgems')
-rw-r--r--mrbgems/mruby-array-ext/mrblib/array.rb2
-rw-r--r--mrbgems/mruby-array-ext/test/array.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/mrbgems/mruby-array-ext/mrblib/array.rb b/mrbgems/mruby-array-ext/mrblib/array.rb
index 18ed5e303..2e66c5fbc 100644
--- a/mrbgems/mruby-array-ext/mrblib/array.rb
+++ b/mrbgems/mruby-array-ext/mrblib/array.rb
@@ -204,7 +204,7 @@ class Array
# for efficiency
def reverse_each(&block)
- return to_enum :sort_by unless block_given?
+ return to_enum :reverse_each unless block_given?
i = self.size - 1
while i>=0
diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb
index 7f296f591..ed1edb5c2 100644
--- a/mrbgems/mruby-array-ext/test/array.rb
+++ b/mrbgems/mruby-array-ext/test/array.rb
@@ -131,3 +131,13 @@ assert("Array#fill") do
assert_equal [1, 2, 3, 27], a.fill(0..1) { |i| i+1 }
assert_raise(ArgumentError) { a.fill }
end
+
+assert("Array#reverse_each") do
+ a = [ "a", "b", "c", "d" ]
+ b = []
+ a.reverse_each do |i|
+ b << i
+ end
+ assert_equal [ "d", "c", "b", "a" ], b
+ assert_equal [ "d", "c", "b", "a" ], a.reverse_each.to_a
+end