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

ruby-changes:12856

From: akr <ko1@a...>
Date: Thu, 20 Aug 2009 02:33:42 +0900 (JST)
Subject: [ruby-changes:12856] Ruby:r24588 (trunk): * enumerator.c (next_init): don't clear feedvalue.

akr	2009-08-20 02:32:56 +0900 (Thu, 20 Aug 2009)

  New Revision: 24588

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24588

  Log:
    * enumerator.c (next_init): don't clear feedvalue.

  Modified files:
    trunk/ChangeLog
    trunk/enumerator.c
    trunk/test/ruby/test_enumerator.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24587)
+++ ChangeLog	(revision 24588)
@@ -1,3 +1,7 @@
+Thu Aug 20 02:32:08 2009  Tanaka Akira  <akr@f...>
+
+	* enumerator.c (next_init): don't clear feedvalue.
+
 Thu Aug 20 01:28:42 2009  Tanaka Akira  <akr@f...>
 
 	* enumerator.c: implement Enumerator#{next_values,peek_values,feed}
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 24587)
+++ enumerator.c	(revision 24588)
@@ -592,7 +592,6 @@
     e->dst = curr;
     e->fib = rb_fiber_new(next_i, obj);
     e->lookahead = Qundef;
-    e->feedvalue = Qundef;
 }
 
 /*
Index: test/ruby/test_enumerator.rb
===================================================================
--- test/ruby/test_enumerator.rb	(revision 24587)
+++ test/ruby/test_enumerator.rb	(revision 24588)
@@ -266,6 +266,40 @@
     assert_raise(TypeError) { e.feed 2 }
   end
 
+  def test_feed_before_first_next
+    o = Object.new
+    def o.each(ary)
+      ary << yield
+      ary << yield
+      ary << yield
+    end
+    ary = []
+    e = o.to_enum(:each, ary)
+    e.feed 1
+    e.next
+    e.next
+    assert_equal([1], ary)
+  end
+
+  def test_rewind_clear_feed
+    o = Object.new
+    def o.each(ary)
+      ary << yield
+      ary << yield
+      ary << yield
+    end
+    ary = []
+    e = o.to_enum(:each, ary)
+    e.next
+    e.feed 1
+    e.next
+    e.feed 2
+    e.rewind
+    e.next
+    e.next
+    assert_equal([1,nil], ary)
+  end
+
   def test_feed_yielder
     x = nil
     e = Enumerator.new {|y| x = y.yield; 10 }

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

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