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

ruby-changes:15314

From: marcandre <ko1@a...>
Date: Sat, 3 Apr 2010 07:26:03 +0900 (JST)
Subject: [ruby-changes:15314] Ruby:r27201 (trunk): * array.c (rb_ary_product): Test for reentry

marcandre	2010-04-03 07:25:49 +0900 (Sat, 03 Apr 2010)

  New Revision: 27201

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

  Log:
    * array.c (rb_ary_product): Test for reentry
    
    * test/ruby/test_array.rb: ditto

  Modified files:
    trunk/array.c
    trunk/test/ruby/test_array.rb

Index: array.c
===================================================================
--- array.c	(revision 27200)
+++ array.c	(revision 27201)
@@ -4117,6 +4117,9 @@
 	/* put it on the result array */
 	if(NIL_P(result)) {
 	    rb_yield(subarray);
+	    if (RBASIC(t0)->klass) {
+		rb_raise(rb_eRuntimeError, "product reentered");
+	    }
 	}
 	else {
 	    rb_ary_push(result, subarray);
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 27200)
+++ test/ruby/test_array.rb	(revision 27201)
@@ -780,6 +780,23 @@
     assert_match(/reentered/, e.message)
   end
 
+  def test_product_with_callcc
+    respond_to?(:callcc, true) or require 'continuation'
+    n = 1000
+    cont = nil
+    ary = [1,2,3]
+    begin
+      ary.product {
+        callcc {|k| cont = k} unless cont
+      }
+    rescue => e
+    end
+    n -= 1
+    cont.call if 0 < n
+    assert_instance_of(RuntimeError, e)
+    assert_match(/reentered/, e.message)
+  end
+
   def test_combination_with_callcc
     respond_to?(:callcc, true) or require 'continuation'
     n = 1000

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

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