[前][次][番号順一覧][スレッド一覧]

ruby-changes:62777

From: Nobuyoshi <ko1@a...>
Date: Mon, 31 Aug 2020 22:14:56 +0900 (JST)
Subject: [ruby-changes:62777] 2e80c8347e (master): Deprecate iterator? method

https://git.ruby-lang.org/ruby.git/commit/?id=2e80c8347e

From 2e80c8347e27f8ecedab56bab105d69efa35cbea Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 19 Jan 2019 11:34:26 +0900
Subject: Deprecate iterator? method

[Feature #15547] [Fix GH-2071]

diff --git a/spec/ruby/core/kernel/iterator_spec.rb b/spec/ruby/core/kernel/iterator_spec.rb
index 7fbdade..a2811dc 100644
--- a/spec/ruby/core/kernel/iterator_spec.rb
+++ b/spec/ruby/core/kernel/iterator_spec.rb
@@ -1,12 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/iterator_spec.rb#L1
 require_relative '../../spec_helper'
 require_relative 'fixtures/classes'
 
-describe "Kernel#iterator?" do
-  it "is a private method" do
-    Kernel.should have_private_instance_method(:iterator?)
+ruby_version_is ""..."2.8" do
+  describe "Kernel#iterator?" do
+    it "is a private method" do
+      Kernel.should have_private_instance_method(:iterator?)
+    end
   end
-end
 
-describe "Kernel.iterator?" do
-  it "needs to be reviewed for spec completeness"
+  describe "Kernel.iterator?" do
+    it "needs to be reviewed for spec completeness"
+  end
 end
diff --git a/vm_eval.c b/vm_eval.c
index e086125..3ada33e 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -2312,7 +2312,6 @@ rb_f_local_variables(VALUE _) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2312
 /*
  *  call-seq:
  *     block_given?   -> true or false
- *     iterator?      -> true or false
  *
  *  Returns <code>true</code> if <code>yield</code> would execute a
  *  block in the current context. The <code>iterator?</code> form
@@ -2330,7 +2329,6 @@ rb_f_local_variables(VALUE _) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2329
  *     try do "hello" end   #=> "hello"
  */
 
-
 static VALUE
 rb_f_block_given_p(VALUE _)
 {
@@ -2346,6 +2344,20 @@ rb_f_block_given_p(VALUE _) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2344
     }
 }
 
+/*
+ *  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
 rb_current_realfilepath(void)
 {
@@ -2361,7 +2373,7 @@ Init_vm_eval(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2373
 {
     rb_define_global_function("eval", rb_f_eval, -1);
     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("catch", rb_f_catch, -1);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]