summaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-28 07:48:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-28 07:48:23 +0000
commit387c80ab833b36d1b804869f1053af29f7920be9 (patch)
tree6ebf79c4e113af57f7aa4587f1e5d8305ed8473a /test/ruby
parent3837488713b91558a3fd2df675b498120eed7517 (diff)
downloadruby-387c80ab833b36d1b804869f1053af29f7920be9.tar.gz
ruby-387c80ab833b36d1b804869f1053af29f7920be9.tar.xz
ruby-387c80ab833b36d1b804869f1053af29f7920be9.zip
add test for enumerator.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_yield.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/ruby/test_yield.rb b/test/ruby/test_yield.rb
index e7de99574..ead0715d4 100644
--- a/test/ruby/test_yield.rb
+++ b/test/ruby/test_yield.rb
@@ -163,7 +163,8 @@ class TestRubyYieldGen < Test::Unit::TestCase
:block_arg => [['&', :arg]],
#: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_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)
@@ -343,4 +344,12 @@ class TestRubyYieldGen < Test::Unit::TestCase
}
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