1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add test for enumerator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-11-28 07:48:23 +00:00
parent c2aef47c84
commit 6272cf8ecd

View file

@ -163,7 +163,8 @@ class TestRubyYieldGen < Test::Unit::TestCase
:block_arg => [['&', :arg]], :block_arg => [['&', :arg]],
#:test => [['def m() yield', :command_args_noblock, ' end; r = m {', :block_param_def, 'vars', '}; undef m; r']] #:test => [['def m() yield', :command_args_noblock, ' end; r = m {', :block_param_def, 'vars', '}; undef m; r']]
:test_proc => [['def m() yield', :command_args_noblock, ' end; r = m {', :block_param_def, 'vars', '}; undef m; r']], :test_proc => [['def m() yield', :command_args_noblock, ' end; r = m {', :block_param_def, 'vars', '}; undef m; r']],
:test_lambda => [['def m() yield', :command_args_noblock, ' end; r = m(&lambda {', :block_param_def, 'vars', '}); undef m; r']] :test_lambda => [['def m() yield', :command_args_noblock, ' end; r = m(&lambda {', :block_param_def, 'vars', '}); undef m; r']],
:test_enum => [['o = Object.new; def o.each() yield', :command_args_noblock, ' end; r1 = r2 = nil; o.each {|*x| r1 = x }; o.to_enum.each {|*x| r2 = x }; [r1, r2]']]
} }
def rename_var(obj) def rename_var(obj)
@ -343,4 +344,12 @@ class TestRubyYieldGen < Test::Unit::TestCase
} }
end end
def test_yield_enum
syntax = Sentence.expand_syntax(Syntax)
Sentence.each(syntax, :test_enum, 4) {|t|
r1, r2 = eval(t.to_s)
assert_equal(r1, r2, "#{t}")
}
end
end end