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

ruby-changes:69494

From: Benoit <ko1@a...>
Date: Fri, 29 Oct 2021 01:54:43 +0900 (JST)
Subject: [ruby-changes:69494] c75df796d8 (master): Update to ruby/spec@21a48d9

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

From c75df796d875b02d7b97974c7fe840f0a9de171f Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Thu, 28 Oct 2021 18:54:01 +0200
Subject: Update to ruby/spec@21a48d9

---
 spec/ruby/command_line/backtrace_limit_spec.rb     |  4 +-
 spec/ruby/command_line/dash_upper_w_spec.rb        | 33 +++++-----
 spec/ruby/command_line/dash_w_spec.rb              |  6 ++
 spec/ruby/command_line/fixtures/backtrace.rb       |  2 +-
 spec/ruby/core/array/shared/join.rb                |  1 +
 spec/ruby/core/enumerable/grep_spec.rb             |  6 ++
 spec/ruby/core/enumerable/grep_v_spec.rb           |  6 ++
 spec/ruby/core/fiber/blocking_spec.rb              | 62 +++++++++++++++++++
 spec/ruby/core/fiber/shared/blocking.rb            | 41 +++++++++++++
 spec/ruby/core/gc/auto_compact_spec.rb             | 19 ++++++
 spec/ruby/core/io/nonblock_spec.rb                 | 70 ++++++++++++++++++++++
 spec/ruby/core/kernel/lambda_spec.rb               | 12 ++++
 spec/ruby/core/kernel/open_spec.rb                 | 12 ++++
 spec/ruby/core/module/deprecate_constant_spec.rb   | 25 ++++++--
 spec/ruby/core/module/private_class_method_spec.rb | 12 ++++
 spec/ruby/core/module/public_class_method_spec.rb  | 16 +++++
 spec/ruby/core/random/default_spec.rb              |  1 -
 spec/ruby/core/string/encode_spec.rb               | 50 ++++++++++++++--
 spec/ruby/core/symbol/to_proc_spec.rb              |  4 +-
 spec/ruby/core/thread/ignore_deadlock_spec.rb      | 21 +++++++
 spec/ruby/core/warning/element_reference_spec.rb   | 10 ++--
 spec/ruby/language/class_variable_spec.rb          | 26 ++++++++
 spec/ruby/language/numbered_parameters_spec.rb     | 14 +++++
 spec/ruby/language/safe_spec.rb                    | 10 ++++
 spec/ruby/language/variables_spec.rb               | 29 +++++++++
 25 files changed, 454 insertions(+), 38 deletions(-)
 create mode 100644 spec/ruby/core/fiber/blocking_spec.rb
 create mode 100644 spec/ruby/core/fiber/shared/blocking.rb
 create mode 100644 spec/ruby/core/gc/auto_compact_spec.rb
 create mode 100644 spec/ruby/core/io/nonblock_spec.rb
 create mode 100644 spec/ruby/core/thread/ignore_deadlock_spec.rb

diff --git a/spec/ruby/command_line/backtrace_limit_spec.rb b/spec/ruby/command_line/backtrace_limit_spec.rb
index c0b243841e6..56afa8efef5 100644
--- a/spec/ruby/command_line/backtrace_limit_spec.rb
+++ b/spec/ruby/command_line/backtrace_limit_spec.rb
@@ -9,7 +9,7 @@ ruby_version_is "3.0" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/backtrace_limit_spec.rb#L9
 
       out.should == <<-MSG
 top
-/fixtures/backtrace.rb:2:in `a': unhandled exception
+/fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
 \tfrom /fixtures/backtrace.rb:6:in `b'
 \tfrom /fixtures/backtrace.rb:10:in `c'
 \t ... 2 levels...
@@ -23,7 +23,7 @@ top https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/backtrace_limit_spec.rb#L23
 
       out.should == <<-MSG
 full_message
-/fixtures/backtrace.rb:2:in `a': unhandled exception
+/fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
 \tfrom /fixtures/backtrace.rb:6:in `b'
 \tfrom /fixtures/backtrace.rb:10:in `c'
 \t ... 2 levels...
diff --git a/spec/ruby/command_line/dash_upper_w_spec.rb b/spec/ruby/command_line/dash_upper_w_spec.rb
index 1b36a1cc227..cbb040a8dd8 100644
--- a/spec/ruby/command_line/dash_upper_w_spec.rb
+++ b/spec/ruby/command_line/dash_upper_w_spec.rb
@@ -19,34 +19,29 @@ describe "The -W command line option with 2" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_upper_w_spec.rb#L19
   it_behaves_like :command_line_verbose, "-W2"
 end
 
+# Regarding the defaults, see core/warning/element_reference_spec.rb
 ruby_version_is "2.7" do
+  describe "The -W command line option with :deprecated" do
+    it "enables deprecation warnings" do
+      ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n"
+    end
+  end
+
   describe "The -W command line option with :no-deprecated" do
     it "suppresses deprecation warnings" do
-      result = ruby_exe('$; = ""', options: '-w', args: '2>&1')
-      result.should =~ /is deprecated/
-
-      result = ruby_exe('$; = ""', options: '-w -W:no-deprecated', args: '2>&1')
-      result.should == ""
+      ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n"
     end
   end
 
-  describe "The -W command line option with :no-experimental" do
-    before do
-      ruby_version_is ""..."3.0" do
-        @src = 'case [0, 1]; in [a, b]; end'
-      end
-
-      ruby_version_is "3.0" do
-        @src = 'warn "This is experimental warning.", category: :experimental'
-      end
+  describe "The -W command line option with :experimental" do
+    it "enables experimental warnings" do
+      ruby_exe('p Warning[:experimental]', options: '-W:experimental').should == "true\n"
     end
+  end
 
+  describe "The -W command line option with :no-experimental" do
     it "suppresses experimental warnings" do
-      result = ruby_exe(@src, args: '2>&1')
-      result.should =~ /is experimental/
-
-      result = ruby_exe(@src, options: '-W:no-experimental', args: '2>&1')
-      result.should == ""
+      ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n"
     end
   end
 end
diff --git a/spec/ruby/command_line/dash_w_spec.rb b/spec/ruby/command_line/dash_w_spec.rb
index 1d93e0347be..c262df12cc8 100644
--- a/spec/ruby/command_line/dash_w_spec.rb
+++ b/spec/ruby/command_line/dash_w_spec.rb
@@ -3,4 +3,10 @@ require_relative 'shared/verbose' https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_w_spec.rb#L3
 
 describe "The -w command line option" do
   it_behaves_like :command_line_verbose, "-w"
+
+  ruby_version_is "2.7" do
+    it "enables both deprecated and experimental warnings" do
+      ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n"
+    end
+  end
 end
diff --git a/spec/ruby/command_line/fixtures/backtrace.rb b/spec/ruby/command_line/fixtures/backtrace.rb
index 19ad638d353..99acae95c89 100644
--- a/spec/ruby/command_line/fixtures/backtrace.rb
+++ b/spec/ruby/command_line/fixtures/backtrace.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/fixtures/backtrace.rb#L1
 def a
-  raise
+  raise 'oops'
 end
 
 def b
diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb
index c443d9a628a..dfdb4ae1e4b 100644
--- a/spec/ruby/core/array/shared/join.rb
+++ b/spec/ruby/core/array/shared/join.rb
@@ -124,6 +124,7 @@ describe :array_join_with_default_separator, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/join.rb#L124
 
       it "warns" do
         -> { [].join }.should complain(/warning: \$, is set to non-nil value/)
+        -> { [].join(nil) }.should complain(/warning: \$, is set to non-nil value/)
       end
     end
   end
diff --git a/spec/ruby/core/enumerable/grep_spec.rb b/spec/ruby/core/enumerable/grep_spec.rb
index 4e66bb85ea3..ac3d3db6412 100644
--- a/spec/ruby/core/enumerable/grep_spec.rb
+++ b/spec/ruby/core/enumerable/grep_spec.rb
@@ -59,6 +59,12 @@ describe "Enumerable#grep" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/grep_spec.rb#L59
       ["abc", "def"].grep(/b/).should == ["abc"]
       $&.should == "z"
     end
+
+    it "does not modify Regexp.last_match without block" do
+      "z" =~ /z/ # Reset last match
+      ["abc", "def"].grep(/b/).should == ["abc"]
+      Regexp.last_match[0].should == "z"
+    end
   end
 
   describe "with a block" do
diff --git a/spec/ruby/core/enumerable/grep_v_spec.rb b/spec/ruby/core/enumerable/grep_v_spec.rb
index 8cae3ac6185..892640efa45 100644
--- a/spec/ruby/core/enumerable/grep_v_spec.rb
+++ b/spec/ruby/core/enumerable/grep_v_spec.rb
@@ -39,6 +39,12 @@ describe "Enumerable#grep_v" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/grep_v_spec.rb#L39
       ["abc", "def"].grep_v(/e/).should == ["abc"]
       $&.should == "z"
     end
+
+    it "does not modify Regexp.last_match without block" do
+      "z" =~ /z/ # Reset last match
+      ["abc", "def"].grep_v(/e/).should == ["abc"]
+      Regexp.last_match[0].should == "z"
+    end
   end
 
   describe "without block" do
diff --git a/spec/ruby/core/fiber/blocking_spec.rb b/spec/ruby/core/fiber/blocking_spec.rb
new file mode 100644
index 00000000000..5ae5fbd5775
--- /dev/null
+++ b/spec/ruby/core/fiber/blocking_spec.rb
@@ -0,0 +1,62 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/fiber/blocking_spec.rb#L1
+require_relative '../../spec_helper'
+require_relative 'shared/blocking'
+
+ruby_version_is "3.0" do
+  require "fiber"
+
+  describe "Fiber.blocking?" do
+    it_behaves_like :non_blocking_fiber, -> { Fiber.blocking? }
+
+    context "when fiber is blocking" do
+      context "root Fiber of the main thread" do
+        it "returns 1 for blocking: true" do
+          fiber = Fiber.new(blocking: true) { Fiber.blocking? }
+          blocking = fiber.resume
+
+          blocking.should == 1
+        end
+      end
+
+      context "root Fiber of a new thread" do
+        it "returns 1 for blocking: true" do
+          thread = Thread.new do
+            fiber = Fiber.new(blocking: true) { Fiber.blocking? }
+            blocking = fiber.resume
+
+            blocking.should == 1
+          end
+
+          thread.join
+        end
+      end
+    end
+  end
+
+  describe "Fiber#blocking?" do
+    it_behaves_like :non_blocking_fiber, -> { Fiber.current.blocking? }
+
+    context "when fiber is blocking" do
+      context "root Fiber of the main thread" do
+        it "returns true for blocking: true" do
+          fiber = Fiber.new(blocking: true) { Fiber.current.blocking? }
+          blocking = fiber.resume
+
+          blocking.should == true
+        end
+      end
+
+      context "root Fiber of a new thread" do
+        it "returns true for blocking: true" do
+          thread = Thr (... truncated)

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

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