diff options
| author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-27 15:44:36 +0000 |
|---|---|---|
| committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-27 15:44:36 +0000 |
| commit | 41fd33e5fe22f13fd178c50adaee39ce53a3c155 (patch) | |
| tree | 210ffad3a18390857eb4aa95252358eed22ab487 /test/ruby | |
| parent | cd0a89b0931d51015e4e94b010926f0c75767cee (diff) | |
merge revision(s) r45562: [Backport #9727]
* array.c (ary_reject): may be turned into a shared array during
the given block. [ruby-dev:48101] [Bug #9727]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_array.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 3a76889e23..235dda0dca 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -2011,6 +2011,22 @@ class TestArray < Test::Unit::TestCase assert_equal([1, 3], [0, 1, 2, 3].reject {|x| x % 2 == 0 }) end + def test_reject_with_callcc + respond_to?(:callcc, true) or require 'continuation' + bug9727 = '[ruby-dev:48101] [Bug #9727]' + cont = nil + a = [*1..10].reject do |i| + callcc {|c| cont = c} if !cont and i == 10 + false + end + if a.size < 1000 + a.unshift(:x) + cont.call + end + assert_equal(1000, a.size, bug9727) + assert_equal([:x, *1..10], a.uniq, bug9727) + end + def test_zip assert_equal([[1, :a, "a"], [2, :b, "b"], [3, nil, "c"]], [1, 2, 3].zip([:a, :b], ["a", "b", "c", "d"])) |
