mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enum.c: move work variables to objects not to let called blocks
access stack area out of scope. [Bug #5801] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3b243514ff
commit
41e331cc36
3 changed files with 370 additions and 293 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Feb 17 13:24:43 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* enum.c: move work variables to objects not to let called blocks
|
||||||
|
access stack area out of scope. [Bug #5801]
|
||||||
|
|
||||||
Fri Feb 17 12:35:55 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
Fri Feb 17 12:35:55 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* tool/merger.rb: remove borders from the commit message which is used
|
* tool/merger.rb: remove borders from the commit message which is used
|
||||||
|
|
|
@ -13,6 +13,16 @@ class TestEnumerable < Test::Unit::TestCase
|
||||||
yield 3
|
yield 3
|
||||||
yield 1
|
yield 1
|
||||||
yield 2
|
yield 2
|
||||||
|
self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@empty = Object.new
|
||||||
|
class << @empty
|
||||||
|
attr_reader :block
|
||||||
|
include Enumerable
|
||||||
|
def each(&block)
|
||||||
|
@block = block
|
||||||
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@verbose = $VERBOSE
|
@verbose = $VERBOSE
|
||||||
|
@ -42,6 +52,10 @@ class TestEnumerable < Test::Unit::TestCase
|
||||||
a = []
|
a = []
|
||||||
@obj.grep(2) {|x| a << x }
|
@obj.grep(2) {|x| a << x }
|
||||||
assert_equal([2, 2], a)
|
assert_equal([2, 2], a)
|
||||||
|
|
||||||
|
bug5801 = '[ruby-dev:45041]'
|
||||||
|
@empty.grep(//)
|
||||||
|
assert_nothing_raised(bug5801) {100.times {@empty.block.call}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_count
|
def test_count
|
||||||
|
@ -109,6 +123,7 @@ class TestEnumerable < Test::Unit::TestCase
|
||||||
def test_first
|
def test_first
|
||||||
assert_equal(1, @obj.first)
|
assert_equal(1, @obj.first)
|
||||||
assert_equal([1, 2, 3], @obj.first(3))
|
assert_equal([1, 2, 3], @obj.first(3))
|
||||||
|
assert_nil(@empty.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sort
|
def test_sort
|
||||||
|
@ -275,6 +290,10 @@ class TestEnumerable < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_take_while
|
def test_take_while
|
||||||
assert_equal([1,2], @obj.take_while {|x| x <= 2})
|
assert_equal([1,2], @obj.take_while {|x| x <= 2})
|
||||||
|
|
||||||
|
bug5801 = '[ruby-dev:45040]'
|
||||||
|
@empty.take_while {true}
|
||||||
|
assert_nothing_raised(bug5801) {100.times {@empty.block.call}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_drop
|
def test_drop
|
||||||
|
|
Loading…
Add table
Reference in a new issue