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

ruby-changes:68548

From: Benoit <ko1@a...>
Date: Thu, 21 Oct 2021 04:43:36 +0900 (JST)
Subject: [ruby-changes:68548] a6c6eef04a (master): Update to ruby/spec@d6921ef

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

From a6c6eef04aaa075f4bbd0eef740d011737afec91 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Wed, 20 Oct 2021 21:41:46 +0200
Subject: Update to ruby/spec@d6921ef

---
 spec/ruby/command_line/backtrace_limit_spec.rb     |  48 +++++
 spec/ruby/command_line/fixtures/backtrace.rb       |  35 ++++
 spec/ruby/core/array/shared/slice.rb               | 217 ++++++++++++++++++++-
 spec/ruby/core/binding/eval_spec.rb                |  16 +-
 spec/ruby/core/conditionvariable/broadcast_spec.rb |  40 ++++
 .../core/conditionvariable/marshal_dump_spec.rb    |   9 +
 spec/ruby/core/conditionvariable/signal_spec.rb    |  77 ++++++++
 spec/ruby/core/conditionvariable/wait_spec.rb      | 175 +++++++++++++++++
 spec/ruby/core/dir/shared/glob.rb                  |  17 ++
 spec/ruby/core/env/shift_spec.rb                   |  39 ++--
 spec/ruby/core/file/utime_spec.rb                  |  12 +-
 spec/ruby/core/float/comparison_spec.rb            |  15 ++
 spec/ruby/core/hash/transform_keys_spec.rb         |  27 +++
 spec/ruby/core/integer/zero_spec.rb                |  21 ++
 spec/ruby/core/kernel/clone_spec.rb                |  92 +++++++--
 spec/ruby/core/kernel/eval_spec.rb                 |  10 +
 spec/ruby/core/kernel/fixtures/classes.rb          |   8 +-
 spec/ruby/core/module/autoload_spec.rb             | 100 +++-------
 spec/ruby/core/module/const_set_spec.rb            |   3 +-
 spec/ruby/core/module/constants_spec.rb            |   6 +
 spec/ruby/core/range/each_spec.rb                  |  24 ++-
 spec/ruby/language/hash_spec.rb                    |  39 ++++
 spec/ruby/language/method_spec.rb                  | 157 ++++++++++++++-
 spec/ruby/language/pattern_matching_spec.rb        | 173 ++++++++++++++--
 spec/ruby/language/proc_spec.rb                    |  26 +++
 spec/ruby/language/range_spec.rb                   |   6 +
 spec/ruby/language/singleton_class_spec.rb         |  17 --
 spec/ruby/language/yield_spec.rb                   |  28 +++
 .../library/conditionvariable/broadcast_spec.rb    |  40 ----
 .../library/conditionvariable/marshal_dump_spec.rb |   9 -
 spec/ruby/library/conditionvariable/signal_spec.rb |  77 --------
 spec/ruby/library/conditionvariable/wait_spec.rb   | 175 -----------------
 spec/ruby/library/ipaddr/new_spec.rb               |  41 ++--
 spec/ruby/library/set/comparison_spec.rb           |  29 +++
 spec/ruby/library/set/initialize_clone_spec.rb     |  18 ++
 spec/ruby/library/set/join_spec.rb                 |  31 +++
 spec/ruby/library/set/sortedset/sortedset_spec.rb  |  22 +++
 .../library/socket/tcpsocket/initialize_spec.rb    |   5 +
 spec/ruby/library/socket/tcpsocket/new_spec.rb     |   5 -
 spec/ruby/library/socket/tcpsocket/shared/new.rb   |  15 ++
 spec/ruby/library/stringio/ungetbyte_spec.rb       |   2 +-
 spec/ruby/security/cve_2010_1330_spec.rb           |   2 -
 spec/ruby/security/cve_2013_4164_spec.rb           |   4 -
 spec/ruby/security/cve_2014_8080_spec.rb           |   1 -
 spec/ruby/security/cve_2018_16396_spec.rb          |   4 -
 spec/ruby/security/cve_2018_8778_spec.rb           |   2 -
 spec/ruby/security/cve_2019_8323_spec.rb           |  54 ++---
 spec/ruby/security/cve_2019_8325_spec.rb           |   6 +-
 48 files changed, 1435 insertions(+), 544 deletions(-)
 create mode 100644 spec/ruby/command_line/backtrace_limit_spec.rb
 create mode 100644 spec/ruby/command_line/fixtures/backtrace.rb
 create mode 100644 spec/ruby/core/conditionvariable/broadcast_spec.rb
 create mode 100644 spec/ruby/core/conditionvariable/marshal_dump_spec.rb
 create mode 100644 spec/ruby/core/conditionvariable/signal_spec.rb
 create mode 100644 spec/ruby/core/conditionvariable/wait_spec.rb
 create mode 100644 spec/ruby/core/integer/zero_spec.rb
 delete mode 100644 spec/ruby/library/conditionvariable/broadcast_spec.rb
 delete mode 100644 spec/ruby/library/conditionvariable/marshal_dump_spec.rb
 delete mode 100644 spec/ruby/library/conditionvariable/signal_spec.rb
 delete mode 100644 spec/ruby/library/conditionvariable/wait_spec.rb
 create mode 100644 spec/ruby/library/set/comparison_spec.rb
 create mode 100644 spec/ruby/library/set/initialize_clone_spec.rb
 create mode 100644 spec/ruby/library/set/join_spec.rb
 create mode 100644 spec/ruby/library/set/sortedset/sortedset_spec.rb
 delete mode 100644 spec/ruby/library/socket/tcpsocket/new_spec.rb

diff --git a/spec/ruby/command_line/backtrace_limit_spec.rb b/spec/ruby/command_line/backtrace_limit_spec.rb
new file mode 100644
index 0000000000..c0b243841e
--- /dev/null
+++ b/spec/ruby/command_line/backtrace_limit_spec.rb
@@ -0,0 +1,48 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/backtrace_limit_spec.rb#L1
+require_relative '../spec_helper'
+
+ruby_version_is "3.0" do
+  describe "The --backtrace-limit command line option" do
+    it "limits top-level backtraces to a given number of entries" do
+      file = fixture(__FILE__ , "backtrace.rb")
+      out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1)
+      out = out.gsub(__dir__, '')
+
+      out.should == <<-MSG
+top
+/fixtures/backtrace.rb:2:in `a': unhandled exception
+\tfrom /fixtures/backtrace.rb:6:in `b'
+\tfrom /fixtures/backtrace.rb:10:in `c'
+\t ... 2 levels...
+      MSG
+    end
+
+    it "affects Exception#full_message" do
+      file = fixture(__FILE__ , "backtrace.rb")
+      out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1")
+      out = out.gsub(__dir__, '')
+
+      out.should == <<-MSG
+full_message
+/fixtures/backtrace.rb:2:in `a': unhandled exception
+\tfrom /fixtures/backtrace.rb:6:in `b'
+\tfrom /fixtures/backtrace.rb:10:in `c'
+\t ... 2 levels...
+      MSG
+    end
+
+    it "does not affect Exception#backtrace" do
+      file = fixture(__FILE__ , "backtrace.rb")
+      out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1")
+      out = out.gsub(__dir__, '')
+
+      out.should == <<-MSG
+backtrace
+/fixtures/backtrace.rb:2:in `a'
+/fixtures/backtrace.rb:6:in `b'
+/fixtures/backtrace.rb:10:in `c'
+/fixtures/backtrace.rb:14:in `d'
+/fixtures/backtrace.rb:29:in `<main>'
+      MSG
+    end
+  end
+end
diff --git a/spec/ruby/command_line/fixtures/backtrace.rb b/spec/ruby/command_line/fixtures/backtrace.rb
new file mode 100644
index 0000000000..19ad638d35
--- /dev/null
+++ b/spec/ruby/command_line/fixtures/backtrace.rb
@@ -0,0 +1,35 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/fixtures/backtrace.rb#L1
+def a
+  raise
+end
+
+def b
+  a
+end
+
+def c
+  b
+end
+
+def d
+  c
+end
+
+arg = ARGV.first
+$stderr.puts arg
+
+case arg
+when 'full_message'
+  begin
+    d
+  rescue => exc
+    puts exc.full_message
+  end
+when 'backtrace'
+  begin
+    d
+  rescue => exc
+    puts exc.backtrace
+  end
+else
+  d
+end
diff --git a/spec/ruby/core/array/shared/slice.rb b/spec/ruby/core/array/shared/slice.rb
index 19e1a3ee2b..cf195ad7a4 100644
--- a/spec/ruby/core/array/shared/slice.rb
+++ b/spec/ruby/core/array/shared/slice.rb
@@ -517,8 +517,9 @@ describe :array_slice, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/slice.rb#L517
   end
 
   it "raises a RangeError if passed a range with a bound that is too large" do
-    -> { "hello".send(@method, bignum_value..(bignum_value + 1)) }.should raise_error(RangeError)
-    -> { "hello".send(@method, 0..bignum_value) }.should raise_error(RangeError)
+    array = [1, 2, 3, 4, 5, 6]
+    -> { array.send(@method, bignum_value..(bignum_value + 1)) }.should raise_error(RangeError)
+    -> { array.send(@method, 0..bignum_value) }.should raise_error(RangeError)
   end
 
   it "can accept endless ranges" do
@@ -533,6 +534,218 @@ describe :array_slice, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/slice.rb#L534
     a.send(@method, eval("(-9...)")).should == nil
   end
 
+  ruby_version_is "3.0" do
+    describe "can be sliced with Enumerator::ArithmeticSequence" do
+      before :each do
+        @array = [0, 1, 2, 3, 4, 5]
+      end
+
+      it "has endless range and positive steps" do
+        @array.send(@method, eval("(0..).step(1)")).should == [0, 1, 2, 3, 4, 5]
+        @array.send(@method, eval("(0..).step(2)")).should == [0, 2, 4]
+        @array.send(@method, eval("(0..).step(10)")).should == [0]
+
+        @array.send(@method, eval("(2..).step(1)")).should == [2, 3, 4, 5]
+        @array.send(@method, eval("(2..).step(2)")).should == [2, 4]
+        @array.send(@method, eval("(2..).step(10)")).should == [2]
+
+        @array.send(@method, eval("(-3..).step(1)")).should == [3, 4, 5]
+        @array.send(@method, eval("(-3..).step(2)")).should == [3, 5]
+        @array.send(@method, eval("(-3..).step(10)")).should == [3]
+      end
+
+      it "has beginless range and positive steps" do
+        # end with zero index
+        @array.send(@method, eval("(..0).step(1)")).should == [0]
+        @array.send(@method, eval("(...0).step(1)")).should == []
+
+        @array.send(@method, eval("(..0).step(2)")).should == [0]
+        @array.send(@method, eval("(...0).step(2)")).should == []
+
+        @array.send(@method, eval("(..0).step(10)")).should == [0]
+        @array.send(@method, eval("(...0).step(10)")).should == []
+
+        # end with positive index
+        @array.send(@method, eval("(..3).step(1)")).should == [0, 1, 2, 3]
+        @array.send(@method, eval("(...3).step(1)")).should == [0, 1, 2]
+
+        @array.send(@method, eval("(..3).step(2)")).should == [0, 2]
+        @array.send(@method, eval("(...3).step(2)")).should == [0, 2]
+
+        @array.send(@method, eval("(..3).step(10)")).should == [0]
+        @array.send(@method, eval("(...3).step(10)")).should == [0]
+
+        # end with negative index
+        @array.send(@method, eval("(..-2).step(1)")).should == [0, 1, 2, 3, 4,]
+        @array.send(@method, eval("(...-2).step(1)")).should == [0, 1, 2, 3]
+
+        @array.send(@method, eval("(..-2).st (... truncated)

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

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