mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Add a frozenness check to Enumerator::Generator#initialize.
* enumerator.c (generator_init): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									8cb0de91c4
								
							
						
					
					
						commit
						075752a836
					
				
					 2 changed files with 6 additions and 0 deletions
				
			
		|  | @ -1178,6 +1178,7 @@ generator_init(VALUE obj, VALUE proc) | ||||||
| { | { | ||||||
|     struct generator *ptr; |     struct generator *ptr; | ||||||
| 
 | 
 | ||||||
|  |     rb_check_frozen(obj); | ||||||
|     TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr); |     TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr); | ||||||
| 
 | 
 | ||||||
|     if (!ptr) { |     if (!ptr) { | ||||||
|  |  | ||||||
|  | @ -419,6 +419,11 @@ class TestEnumerator < Test::Unit::TestCase | ||||||
|     a = [] |     a = [] | ||||||
|     assert_equal(:foo, g2.each {|x| a << x }) |     assert_equal(:foo, g2.each {|x| a << x }) | ||||||
|     assert_equal([1, 2, 3], a) |     assert_equal([1, 2, 3], a) | ||||||
|  | 
 | ||||||
|  |     g.freeze | ||||||
|  |     assert_raise(RuntimeError) { | ||||||
|  |       g.__send__ :initialize, proc { |y| y << 4 << 5 } | ||||||
|  |     } | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def test_generator_args |   def test_generator_args | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 knu
						knu