mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Update mruby-enumerator test to conform the last update.
This commit is contained in:
@@ -19,11 +19,8 @@ assert 'Enumerator.new' do
|
||||
assert_equal [:x,:y,:z], [:x,:y,:z].each.map{|i| i}.sort
|
||||
assert_equal [[:x,1],[:y,2]], {x:1, y:2}.each.map{|i| i}.sort
|
||||
assert_equal [1,2,3], @obj.to_enum(:foo, 1,2,3).to_a
|
||||
assert_equal [1,2,3], Enumerator.new(@obj, :foo, 1,2,3).to_a
|
||||
assert_equal [1,2,3], Enumerator.new { |y| i = 0; loop { y << (i += 1) } }.take(3)
|
||||
assert_equal [], Enumerator.new(false, :__id__).to_a
|
||||
assert_raise(ArgumentError) { Enumerator.new }
|
||||
assert_raise(ArgumentError) { @obj.to_enum }
|
||||
|
||||
# examples
|
||||
fib = Enumerator.new do |y|
|
||||
@@ -94,11 +91,11 @@ end
|
||||
assert 'Enumerator#inspect' do
|
||||
e = (0..10).each
|
||||
assert_equal('#<Enumerator: 0..10:each>', e.inspect)
|
||||
e = Enumerator.new('FooObject', :foo, 1)
|
||||
e = 'FooObject'.enum_for(:foo, 1)
|
||||
assert_equal('#<Enumerator: "FooObject":foo(1)>', e.inspect)
|
||||
e = Enumerator.new('FooObject', :foo, 1, 2, 3)
|
||||
e = 'FooObject'.enum_for(:foo, 1, 2, 3)
|
||||
assert_equal('#<Enumerator: "FooObject":foo(1, 2, 3)>', e.inspect)
|
||||
e = Enumerator.new(nil, :to_s)
|
||||
e = nil.enum_for(:to_s)
|
||||
assert_equal('#<Enumerator: nil:to_s>', e.inspect)
|
||||
end
|
||||
|
||||
@@ -422,7 +419,6 @@ end
|
||||
|
||||
assert 'Kernel#to_enum' do
|
||||
assert_equal Enumerator, [].to_enum.class
|
||||
assert_raise(ArgumentError){ nil.to_enum }
|
||||
end
|
||||
|
||||
assert 'modifying existing methods' do
|
||||
|
||||
Reference in New Issue
Block a user