ruby-changes:65402
From: Jeremy <ko1@a...>
Date: Sun, 7 Mar 2021 06:56:37 +0900 (JST)
Subject: [ruby-changes:65402] 68d028578a (master): Undef Enumerator::Chain#{feed, next, next_values, peek, peek_values}
https://git.ruby-lang.org/ruby.git/commit/?id=68d028578a From 68d028578a5975fe6c44d29c502615ff9af72927 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Fri, 5 Mar 2021 12:47:00 -0800 Subject: Undef Enumerator::Chain#{feed,next,next_values,peek,peek_values} Previously these methods were defined but raised TypeError, which seems worse. --- enumerator.c | 5 +++++ test/ruby/test_enumerator.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/enumerator.c b/enumerator.c index 45620f3..a43434d 100644 --- a/enumerator.c +++ b/enumerator.c @@ -4200,6 +4200,11 @@ InitVM_Enumerator(void) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L4200 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); diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index 4e698fc..4342c10 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -832,6 +832,12 @@ class TestEnumerator < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enumerator.rb#L832 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 } -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/