Project

General

Profile

Feature #15547 ยป 0001-Deprecate-iterator-method.patch

nobu (Nobuyoshi Nakada), 01/19/2019 02:35 AM

View differences:

spec/ruby/core/kernel/iterator_spec.rb
1 1
require_relative '../../spec_helper'
2 2
require_relative 'fixtures/classes'
3 3

  
4
describe "Kernel#iterator?" do
5
  it "is a private method" do
6
    Kernel.should have_private_instance_method(:iterator?)
4
ruby_version_is ""..."2.7" do
5
  describe "Kernel#iterator?" do
6
    it "is a private method" do
7
      Kernel.should have_private_instance_method(:iterator?)
8
    end
7 9
  end
8
end
9 10

  
10
describe "Kernel.iterator?" do
11
  it "needs to be reviewed for spec completeness"
11
  describe "Kernel.iterator?" do
12
    it "needs to be reviewed for spec completeness"
13
  end
12 14
end
vm_eval.c
2095 2095
/*
2096 2096
 *  call-seq:
2097 2097
 *     block_given?   -> true or false
2098
 *     iterator?      -> true or false
2099 2098
 *
2100 2099
 *  Returns <code>true</code> if <code>yield</code> would execute a
2101 2100
 *  block in the current context. The <code>iterator?</code> form
......
2113 2112
 *     try do "hello" end   #=> "hello"
2114 2113
 */
2115 2114

  
2116

  
2117 2115
static VALUE
2118 2116
rb_f_block_given_p(void)
2119 2117
{
......
2129 2127
    }
2130 2128
}
2131 2129

  
2130
/*
2131
 *  call-seq:
2132
 *     iterator?      -> true or false
2133
 *
2134
 *  Deprecated.  Use block_given? instead.
2135
 */
2136

  
2137
static VALUE
2138
rb_f_iterator_p(void)
2139
{
2140
    rb_warning("iterator? is deprecated; use block_given? instead");
2141
    return rb_f_block_given_p();
2142
}
2143

  
2132 2144
VALUE
2133 2145
rb_current_realfilepath(void)
2134 2146
{
......
2144 2156
{
2145 2157
    rb_define_global_function("eval", rb_f_eval, -1);
2146 2158
    rb_define_global_function("local_variables", rb_f_local_variables, 0);
2147
    rb_define_global_function("iterator?", rb_f_block_given_p, 0);
2159
    rb_define_global_function("iterator?", rb_f_iterator_p, 0);
2148 2160
    rb_define_global_function("block_given?", rb_f_block_given_p, 0);
2149 2161

  
2150 2162
    rb_define_global_function("catch", rb_f_catch, -1);
2151
-