1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Deprecate iterator? method

[Feature #15547] [Fix GH-2071]
This commit is contained in:
Nobuyoshi Nakada 2019-01-19 11:34:26 +09:00
parent c23c880f56
commit 2e80c8347e
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 24 additions and 10 deletions

View file

@ -1,12 +1,14 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#iterator?" do ruby_version_is ""..."2.8" do
it "is a private method" do describe "Kernel#iterator?" do
Kernel.should have_private_instance_method(:iterator?) it "is a private method" do
Kernel.should have_private_instance_method(:iterator?)
end
end
describe "Kernel.iterator?" do
it "needs to be reviewed for spec completeness"
end end
end end
describe "Kernel.iterator?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -2312,7 +2312,6 @@ rb_f_local_variables(VALUE _)
/* /*
* call-seq: * call-seq:
* block_given? -> true or false * block_given? -> true or false
* iterator? -> true or false
* *
* Returns <code>true</code> if <code>yield</code> would execute a * Returns <code>true</code> if <code>yield</code> would execute a
* block in the current context. The <code>iterator?</code> form * block in the current context. The <code>iterator?</code> form
@ -2330,7 +2329,6 @@ rb_f_local_variables(VALUE _)
* try do "hello" end #=> "hello" * try do "hello" end #=> "hello"
*/ */
static VALUE static VALUE
rb_f_block_given_p(VALUE _) rb_f_block_given_p(VALUE _)
{ {
@ -2346,6 +2344,20 @@ rb_f_block_given_p(VALUE _)
} }
} }
/*
* call-seq:
* iterator? -> true or false
*
* Deprecated. Use block_given? instead.
*/
static VALUE
rb_f_iterator_p(VALUE self)
{
rb_warn_deprecated("iterator?", "block_given?");
return rb_f_block_given_p(self);
}
VALUE VALUE
rb_current_realfilepath(void) rb_current_realfilepath(void)
{ {
@ -2361,7 +2373,7 @@ Init_vm_eval(void)
{ {
rb_define_global_function("eval", rb_f_eval, -1); rb_define_global_function("eval", rb_f_eval, -1);
rb_define_global_function("local_variables", rb_f_local_variables, 0); rb_define_global_function("local_variables", rb_f_local_variables, 0);
rb_define_global_function("iterator?", rb_f_block_given_p, 0); rb_define_global_function("iterator?", rb_f_iterator_p, 0);
rb_define_global_function("block_given?", rb_f_block_given_p, 0); rb_define_global_function("block_given?", rb_f_block_given_p, 0);
rb_define_global_function("catch", rb_f_catch, -1); rb_define_global_function("catch", rb_f_catch, -1);