summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorksss <[email protected]>2014-03-15 00:45:58 +0900
committerksss <[email protected]>2014-03-15 08:21:39 +0900
commit0bb7f5e950de68cfcb188fa7df79dc2537ee45c1 (patch)
tree5099c0afcf996b2531cc019aca077e54512258ea
parent9447c637a558e30d6315fd712f91b349587a8a34 (diff)
downloadmruby-0bb7f5e950de68cfcb188fa7df79dc2537ee45c1.tar.gz
mruby-0bb7f5e950de68cfcb188fa7df79dc2537ee45c1.zip
fix variable name typo
-rw-r--r--mrbgems/mruby-enumerator/mrblib/enumerator.rb2
-rw-r--r--mrbgems/mruby-enumerator/test/enumerator.rb15
2 files changed, 16 insertions, 1 deletions
diff --git a/mrbgems/mruby-enumerator/mrblib/enumerator.rb b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
index cf909bac5..7bf354d9c 100644
--- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb
+++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
@@ -206,7 +206,7 @@ class Enumerator
# # => foo:2
#
def with_object object
- return to_enum :with_object, offset unless block_given?
+ return to_enum :with_object, object unless block_given?
each do |i|
yield [i,object]
diff --git a/mrbgems/mruby-enumerator/test/enumerator.rb b/mrbgems/mruby-enumerator/test/enumerator.rb
index 71e70733c..857615991 100644
--- a/mrbgems/mruby-enumerator/test/enumerator.rb
+++ b/mrbgems/mruby-enumerator/test/enumerator.rb
@@ -72,6 +72,21 @@ assert 'Enumerator#with_object' do
assert_equal([55, 3628800], ret)
end
+assert 'Enumerator#with_object arguments' do
+ to_three = Enumerator.new do |y|
+ 3.times do |x|
+ y << x
+ end
+ end
+
+ a = []
+ to_three_with_string = to_three.with_object("foo")
+ to_three_with_string.each do |x,string|
+ a << "#{string}:#{x}"
+ end
+ assert_equal ["foo:0","foo:1","foo:2"], a
+end
+
assert 'Enumerator#inspect' do
e = (0..10).each
assert_equal("#<Enumerator: 0..10:each>", e.inspect)