mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Undef Enumerator::Chain#{feed,next,next_values,peek,peek_values}
Previously these methods were defined but raised TypeError, which seems worse.
This commit is contained in:
		
							parent
							
								
									e1d16a9e56
								
							
						
					
					
						commit
						68d028578a
					
				
				
				Notes:
				
					git
				
				2021-03-07 06:56:44 +09:00 
				
			
			
			
		
		
					 2 changed files with 11 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -4200,6 +4200,11 @@ InitVM_Enumerator(void)
 | 
			
		|||
    rb_define_method(rb_cEnumChain, "size", enum_chain_size, 0);
 | 
			
		||||
    rb_define_method(rb_cEnumChain, "rewind", enum_chain_rewind, 0);
 | 
			
		||||
    rb_define_method(rb_cEnumChain, "inspect", enum_chain_inspect, 0);
 | 
			
		||||
    rb_undef_method(rb_cEnumChain, "feed");
 | 
			
		||||
    rb_undef_method(rb_cEnumChain, "next");
 | 
			
		||||
    rb_undef_method(rb_cEnumChain, "next_values");
 | 
			
		||||
    rb_undef_method(rb_cEnumChain, "peek");
 | 
			
		||||
    rb_undef_method(rb_cEnumChain, "peek_values");
 | 
			
		||||
 | 
			
		||||
    /* ArithmeticSequence */
 | 
			
		||||
    rb_cArithSeq = rb_define_class_under(rb_cEnumerator, "ArithmeticSequence", rb_cEnumerator);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -832,6 +832,12 @@ class TestEnumerator < Test::Unit::TestCase
 | 
			
		|||
    assert_equal(33, chain.next)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_chain_undef_methods
 | 
			
		||||
    chain = [1].to_enum + [2].to_enum
 | 
			
		||||
    meths = (chain.methods & [:feed, :next, :next_values, :peek, :peek_values])
 | 
			
		||||
    assert_equal(0, meths.size)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_produce
 | 
			
		||||
    assert_raise(ArgumentError) { Enumerator.produce }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue