From f8cb9c861ad95f081c97a18e8f7df4e5f623db6e Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 8 May 2008 01:04:20 +0000 Subject: * test/ruby/test_array.rb (test_sort_with_callcc): test for [ruby-core:16679]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_array.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby/test_array.rb') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 11be73c733..2ed15ffec0 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1125,6 +1125,25 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[], @cls[].sort!) end + def test_sort_with_callcc + respond_to?(:callcc) or require 'continuation' + n = 1000 + cont = nil + ary = (1..100).to_a + begin + ary.sort! {|a,b| + callcc {|k| cont = k} unless cont + assert_equal(100, ary.size, '[ruby-core:16679]') + a <=> b + } + rescue => e + end + n -= 1 + cont.call if 0 < n + assert_instance_of(RuntimeError, e, '[ruby-core:16679]') + assert_match(/reentered/, e.message, '[ruby-core:16679]') + end + def test_to_a a = @cls[ 1, 2, 3 ] a_id = a.__id__ -- cgit v1.2.3