ruby-changes:30184
From: knu <ko1@a...>
Date: Mon, 29 Jul 2013 21:20:31 +0900 (JST)
Subject: [ruby-changes:30184] knu:r42236 (trunk): Add a frozenness check test for Enumerator::Lazy#initialize.
knu 2013-07-29 21:20:19 +0900 (Mon, 29 Jul 2013) New Revision: 42236 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42236 Log: Add a frozenness check test for Enumerator::Lazy#initialize. * test/ruby/test_lazy_enumerator.rb (TestLazyEnumerator#test_initialize): Make sure Enumerator::Lazy#initialize raises error if the object is frozen. The check was performed by rb_ivar_set() before rb_check_frozen() was added to enumerator_init(). Modified files: trunk/ChangeLog trunk/test/ruby/test_lazy_enumerator.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42235) +++ ChangeLog (revision 42236) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 29 21:15:30 2013 Akinori MUSHA <knu@i...> + + * test/ruby/test_lazy_enumerator.rb + (TestLazyEnumerator#test_initialize): Make sure + Enumerator::Lazy#initialize raises error if the object is + frozen. The check was performed by rb_ivar_set() before + rb_check_frozen() was added to enumerator_init(). + Mon Jul 29 21:06:42 2013 Akinori MUSHA <knu@i...> * enumerator.c (enumerator_init): Add a frozenness check to Index: test/ruby/test_lazy_enumerator.rb =================================================================== --- test/ruby/test_lazy_enumerator.rb (revision 42235) +++ test/ruby/test_lazy_enumerator.rb (revision 42236) @@ -22,6 +22,12 @@ class TestLazyEnumerator < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_lazy_enumerator.rb#L22 assert_equal([1, 2, 3], [1, 2, 3].lazy.to_a) assert_equal([1, 2, 3], Enumerator::Lazy.new([1, 2, 3]){|y, v| y << v}.to_a) assert_raise(ArgumentError) { Enumerator::Lazy.new([1, 2, 3]) } + + a = [1, 2, 3].lazy + a.freeze + assert_raise(RuntimeError) { + a.__send__ :initialize, [4, 5], &->(y, *v) { y << yield(*v) } + } end def test_each_args -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/