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

ruby-changes:70805

From: Benoit <ko1@a...>
Date: Tue, 11 Jan 2022 00:30:51 +0900 (JST)
Subject: [ruby-changes:70805] 4053e8ba0d (master): Update to ruby/spec@226cfdc

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

From 4053e8ba0d39b688440fedee2ab3fffabcd64312 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Mon, 10 Jan 2022 16:29:54 +0100
Subject: Update to ruby/spec@226cfdc

---
 spec/ruby/core/array/pack/a_spec.rb         | 11 ++++++
 spec/ruby/core/array/pack/b_spec.rb         |  7 +++-
 spec/ruby/core/array/pack/h_spec.rb         |  5 +++
 spec/ruby/core/array/pack/shared/float.rb   |  8 ++++
 spec/ruby/core/array/pack/u_spec.rb         | 10 +++++
 spec/ruby/core/array/pack/z_spec.rb         | 10 +++++
 spec/ruby/core/file/shared/fnmatch.rb       |  8 ++++
 spec/ruby/core/hash/to_a_spec.rb            | 10 +++++
 spec/ruby/core/hash/transform_keys_spec.rb  |  4 +-
 spec/ruby/core/integer/constants_spec.rb    | 20 ++++++++--
 spec/ruby/core/io/ungetc_spec.rb            |  2 +-
 spec/ruby/core/kernel/match_spec.rb         | 10 ++++-
 spec/ruby/core/math/log2_spec.rb            |  2 +-
 spec/ruby/core/module/include_spec.rb       | 21 ++++++++++
 spec/ruby/core/module/prepend_spec.rb       |  2 +-
 spec/ruby/core/numeric/shared/step.rb       |  1 -
 spec/ruby/core/numeric/step_spec.rb         |  2 -
 spec/ruby/core/proc/compose_spec.rb         |  8 ++++
 spec/ruby/core/proc/eql_spec.rb             |  2 +-
 spec/ruby/core/proc/equal_value_spec.rb     |  2 +-
 spec/ruby/core/random/default_spec.rb       | 32 +++++++++++++++-
 spec/ruby/core/random/raw_seed_spec.rb      |  6 ---
 spec/ruby/core/random/shared/urandom.rb     | 23 -----------
 spec/ruby/core/random/urandom_spec.rb       | 25 ++++++++++++
 spec/ruby/core/string/allocate_spec.rb      |  2 +-
 spec/ruby/core/string/bytesize_spec.rb      |  2 +-
 spec/ruby/core/string/element_set_spec.rb   |  6 +++
 spec/ruby/core/string/shared/length.rb      | 24 ++++++------
 spec/ruby/core/string/split_spec.rb         |  4 ++
 spec/ruby/fixtures/class.rb                 |  4 ++
 spec/ruby/language/case_spec.rb             |  9 +++++
 spec/ruby/language/class_spec.rb            | 13 +++++++
 spec/ruby/language/constants_spec.rb        | 14 +++++++
 spec/ruby/language/def_spec.rb              |  2 +-
 spec/ruby/language/pattern_matching_spec.rb | 59 +++++++++++++++++++++++++++++
 spec/ruby/language/variables_spec.rb        | 21 +++++-----
 spec/ruby/library/pp/pp_spec.rb             |  7 ++++
 spec/ruby/optional/capi/ext/proc_spec.c     | 59 +++++++++++++++++++++++++++++
 spec/ruby/optional/capi/ext/thread_spec.c   | 36 ++++++++++++++++++
 spec/ruby/optional/capi/proc_spec.rb        | 27 +++++++++++++
 spec/ruby/optional/capi/thread_spec.rb      | 10 +++++
 spec/ruby/security/cve_2019_8322_spec.rb    | 24 ++++++------
 42 files changed, 470 insertions(+), 84 deletions(-)
 delete mode 100644 spec/ruby/core/random/raw_seed_spec.rb
 delete mode 100644 spec/ruby/core/random/shared/urandom.rb
 create mode 100644 spec/ruby/core/random/urandom_spec.rb

diff --git a/spec/ruby/core/array/pack/a_spec.rb b/spec/ruby/core/array/pack/a_spec.rb
index 7af7a16c68d..f4a40502c27 100644
--- a/spec/ruby/core/array/pack/a_spec.rb
+++ b/spec/ruby/core/array/pack/a_spec.rb
@@ -12,6 +12,17 @@ describe "Array#pack with format 'A'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/a_spec.rb#L12
   it_behaves_like :array_pack_string, 'A'
   it_behaves_like :array_pack_taint, 'A'
 
+  it "calls #to_str to convert an Object to a String" do
+    obj = mock("pack A string")
+    obj.should_receive(:to_str).and_return("``abcdef")
+    [obj].pack("A*").should == "``abcdef"
+  end
+
+  it "will not implicitly convert a number to a string" do
+    -> { [0].pack('A') }.should raise_error(TypeError)
+    -> { [0].pack('a') }.should raise_error(TypeError)
+  end
+
   it "adds all the bytes to the output when passed the '*' modifier" do
     ["abc"].pack("A*").should == "abc"
   end
diff --git a/spec/ruby/core/array/pack/b_spec.rb b/spec/ruby/core/array/pack/b_spec.rb
index 872c1b88d58..ec82b7d1abf 100644
--- a/spec/ruby/core/array/pack/b_spec.rb
+++ b/spec/ruby/core/array/pack/b_spec.rb
@@ -13,11 +13,16 @@ describe "Array#pack with format 'B'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/b_spec.rb#L13
   it_behaves_like :array_pack_taint, 'B'
 
   it "calls #to_str to convert an Object to a String" do
-    obj = mock("pack H string")
+    obj = mock("pack B string")
     obj.should_receive(:to_str).and_return("``abcdef")
     [obj].pack("B*").should == "\x2a"
   end
 
+  it "will not implicitly convert a number to a string" do
+    -> { [0].pack('B') }.should raise_error(TypeError)
+    -> { [0].pack('b') }.should raise_error(TypeError)
+  end
+
   it "encodes one bit for each character starting with the most significant bit" do
     [ [["0"], "\x00"],
       [["1"], "\x80"]
diff --git a/spec/ruby/core/array/pack/h_spec.rb b/spec/ruby/core/array/pack/h_spec.rb
index 85a875fc8b4..2c1dac8d4a4 100644
--- a/spec/ruby/core/array/pack/h_spec.rb
+++ b/spec/ruby/core/array/pack/h_spec.rb
@@ -18,6 +18,11 @@ describe "Array#pack with format 'H'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/h_spec.rb#L18
     [obj].pack("H").should == "\xa0"
   end
 
+  it "will not implicitly convert a number to a string" do
+    -> { [0].pack('H') }.should raise_error(TypeError)
+    -> { [0].pack('h') }.should raise_error(TypeError)
+  end
+
   it "encodes the first character as the most significant nibble when passed no count modifier" do
     ["ab"].pack("H").should == "\xa0"
   end
diff --git a/spec/ruby/core/array/pack/shared/float.rb b/spec/ruby/core/array/pack/shared/float.rb
index c6b194007fe..ba174a071aa 100644
--- a/spec/ruby/core/array/pack/shared/float.rb
+++ b/spec/ruby/core/array/pack/shared/float.rb
@@ -53,6 +53,14 @@ describe :array_pack_float_le, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/shared/float.rb#L53
   it "encodes a negative Float outside the range of a single precision float" do
     [-1e150].pack(pack_format).should == "\x00\x00\x80\xff"
   end
+
+  it "encodes a bignum as a float" do
+    [2 ** 65].pack(pack_format).should == [(2 ** 65).to_f].pack(pack_format)
+  end
+
+  it "encodes a rational as a float" do
+    [Rational(3, 4)].pack(pack_format).should == [Rational(3, 4).to_f].pack(pack_format)
+  end
 end
 
 describe :array_pack_float_be, shared: true do
diff --git a/spec/ruby/core/array/pack/u_spec.rb b/spec/ruby/core/array/pack/u_spec.rb
index fe969cbb2d3..b20093a6479 100644
--- a/spec/ruby/core/array/pack/u_spec.rb
+++ b/spec/ruby/core/array/pack/u_spec.rb
@@ -18,6 +18,16 @@ describe "Array#pack with format 'u'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/u_spec.rb#L18
   it_behaves_like :array_pack_arguments, 'u'
   it_behaves_like :array_pack_taint, 'u'
 
+  it "calls #to_str to convert an Object to a String" do
+    obj = mock("pack u string")
+    obj.should_receive(:to_str).and_return("``abcdef")
+    [obj].pack("u*").should == "(8&!A8F-D968`\n"
+  end
+
+  it "will not implicitly convert a number to a string" do
+    -> { [0].pack('u') }.should raise_error(TypeError)
+  end
+
   it "encodes an empty string as an empty string" do
     [""].pack("u").should == ""
   end
diff --git a/spec/ruby/core/array/pack/z_spec.rb b/spec/ruby/core/array/pack/z_spec.rb
index 82ce7b4a1ca..5ad3afd69e1 100644
--- a/spec/ruby/core/array/pack/z_spec.rb
+++ b/spec/ruby/core/array/pack/z_spec.rb
@@ -12,6 +12,16 @@ describe "Array#pack with format 'Z'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/pack/z_spec.rb#L12
   it_behaves_like :array_pack_string, 'Z'
   it_behaves_like :array_pack_taint, 'Z'
 
+  it "calls #to_str to convert an Object to a String" do
+    obj = mock("pack Z string")
+    obj.should_receive(:to_str).and_return("``abcdef")
+    [obj].pack("Z*").should == "``abcdef\x00"
+  end
+
+  it "will not implicitly convert a number to a string" do
+    -> { [0].pack('Z') }.should raise_error(TypeError)
+  end
+
   it "adds all the bytes and appends a NULL byte when passed the '*' modifier" do
     ["abc"].pack("Z*").should == "abc\x00"
   end
diff --git a/spec/ruby/core/file/shared/fnmatch.rb b/spec/ruby/core/file/shared/fnmatch.rb
index a8488fd30a5..00682bb64ce 100644
--- a/spec/ruby/core/file/shared/fnmatch.rb
+++ b/spec/ruby/core/file/shared/fnmatch.rb
@@ -75,6 +75,14 @@ describe :file_fnmatch, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/shared/fnmatch.rb#L75
     File.send(@method, 'c*t', 'c/a/b/t').should == true
   end
 
+  it "does not match unterminated range of characters" do
+    File.send(@method, 'abc[de', 'abcd').should == false
+  end
+
+  it "does not match unterminated range of characters as a literal" do
+    File.send(@method, 'abc[de', 'abc[de').should == false
+  end
+
   it "matches ranges of characters using bracket expression (e.g. [a-z])" do
     File.send(@method, 'ca[a-z]', 'cat').should == true
   end
diff --git a/spec/ruby/core/hash/to_a_spec.rb b/spec/ruby/core/hash/to_a_spec.rb
index 46f871389a0..6f6f74f73ba 100644
--- a/spec/ruby/core/hash/to_a_spec.rb
+++ b/spec/ruby/core/hash/to_a_spec.rb
@@ -36,4 +36,14 @@ describe "Hash#to_a" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/hash/to_a_spec.rb#L36
       {}.untrust.to_a.untrusted?.should be_true
     end
   end
+
+  ruby_version_is '2.7'...'3.0' do
+    it "returns a not tainted array if self is tainted" do
+      {}.taint.to_a.tainted?.should be_false
+    end
+
+    it "returns a trusted array if self is untrusted" do
+      {}.untrust.to_a.untrusted?.should be_false
+    end
+  end
 end
diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb
index 8ee1a2cd6d0..1e82ff65477 100644
--- a/spec/ruby/core/hash/transform_keys_spec.rb
+++ b/spec/ruby/core/hash/transform_keys_spec.rb
@@ -80,7 +80,7 @@ describe "Hash#transform_keys!" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/hash/transform_keys_spec.rb#L80
   end
 
   ruby_version_is ""..."3.0.2" do # https://bugs.ru (... truncated)

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

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