[前][次][番号順一覧][スレッド一覧]

ruby-changes:2552

From: ko1@a...
Date: 28 Nov 2007 16:49:33 +0900
Subject: [ruby-changes:2552] akr - Ruby:r14043 (trunk): add test for enumerator.

akr	2007-11-28 16:48:23 +0900 (Wed, 28 Nov 2007)

  New Revision: 14043

  Modified files:
    trunk/test/ruby/test_yield.rb

  Log:
    add test for enumerator.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_yield.rb?r1=14043&r2=14042

Index: test/ruby/test_yield.rb
===================================================================
--- test/ruby/test_yield.rb	(revision 14042)
+++ test/ruby/test_yield.rb	(revision 14043)
@@ -163,7 +163,8 @@
     :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 @@
     }
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]