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

ruby-changes:63773

From: Benoit <ko1@a...>
Date: Fri, 27 Nov 2020 22:56:14 +0900 (JST)
Subject: [ruby-changes:63773] f02d2f82bf (master): Update to ruby/spec@ac878ad

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

From f02d2f82bf10351f480ea312f40cb840e2437f93 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Fri, 27 Nov 2020 14:55:31 +0100
Subject: Update to ruby/spec@ac878ad


diff --git a/spec/ruby/core/dir/fixtures/common.rb b/spec/ruby/core/dir/fixtures/common.rb
index 96dba56..71b1438 100644
--- a/spec/ruby/core/dir/fixtures/common.rb
+++ b/spec/ruby/core/dir/fixtures/common.rb
@@ -36,6 +36,8 @@ module DirSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/fixtures/common.rb#L36
         .dotfile
         .dotsubdir/.dotfile
         .dotsubdir/nondotfile
+        nested/.dotsubir/.dotfile
+        nested/.dotsubir/nondotfile
 
         deeply/.dotfile
         deeply/nested/.dotfile.ext
@@ -160,6 +162,7 @@ module DirSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/fixtures/common.rb#L162
       dir_filename_ordering
       file_one.ext
       file_two.ext
+      nested
       nondotfile
       special
       subdir_one
diff --git a/spec/ruby/core/dir/glob_spec.rb b/spec/ruby/core/dir/glob_spec.rb
index d4888ee..9b6e2b2 100644
--- a/spec/ruby/core/dir/glob_spec.rb
+++ b/spec/ruby/core/dir/glob_spec.rb
@@ -59,6 +59,8 @@ describe "Dir.glob" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/glob_spec.rb#L59
       deeply/nested/directory/
       deeply/nested/directory/structure/
       dir/
+      nested/
+      nested/.dotsubir/
       special/
       special/test{1}/
       subdir_one/
@@ -68,6 +70,18 @@ describe "Dir.glob" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/glob_spec.rb#L70
     Dir.glob('**/', File::FNM_DOTMATCH).sort.should == expected
   end
 
+  it "recursively matches files and directories in nested dot subdirectory with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH" do
+    expected = %w[
+      nested/.
+      nested/.dotsubir
+      nested/.dotsubir/.
+      nested/.dotsubir/.dotfile
+      nested/.dotsubir/nondotfile
+    ]
+
+    Dir.glob('nested/**/*', File::FNM_DOTMATCH).sort.should == expected.sort
+  end
+
   # This is a separate case to check **/ coming after a constant
   # directory as well.
   it "recursively matches any subdirectories except './' or '../' with '**/' and option File::FNM_DOTMATCH" do
@@ -80,6 +94,8 @@ describe "Dir.glob" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/glob_spec.rb#L94
       ./deeply/nested/directory/
       ./deeply/nested/directory/structure/
       ./dir/
+      ./nested/
+      ./nested/.dotsubir/
       ./special/
       ./special/test{1}/
       ./subdir_one/
diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb
index fcaa0d8..f6d41ba 100644
--- a/spec/ruby/core/dir/shared/glob.rb
+++ b/spec/ruby/core/dir/shared/glob.rb
@@ -53,6 +53,7 @@ describe :dir_glob, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/shared/glob.rb#L53
       dir_filename_ordering
       file_one.ext
       file_two.ext
+      nested
       nondotfile
       special
       subdir_one
@@ -156,6 +157,7 @@ describe :dir_glob, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/shared/glob.rb#L157
       dir_filename_ordering
       file_one.ext
       file_two.ext
+      nested
       nondotfile
       special
       subdir_one
@@ -177,6 +179,7 @@ describe :dir_glob, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/dir/shared/glob.rb#L179
       deeply/nested/directory/
       deeply/nested/directory/structure/
       dir/
+      nested/
       special/
       special/test{1}/
       subdir_one/
diff --git a/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb b/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
new file mode 100644
index 0000000..005886a
--- /dev/null
+++ b/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
@@ -0,0 +1,47 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb#L1
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
+
+ruby_version_is "2.7" do
+  describe "Hash.ruby2_keywords_hash?" do
+    it "returns false if the Hash is not a keywords Hash" do
+      Hash.ruby2_keywords_hash?({}).should == false
+    end
+
+    it "returns true if the Hash is a keywords Hash marked by Module#ruby2_keywords" do
+      obj = Class.new {
+        ruby2_keywords def m(*args)
+          args.last
+        end
+      }.new
+      Hash.ruby2_keywords_hash?(obj.m(a: 1)).should == true
+    end
+
+    it "raises TypeError for non-Hash" do
+      -> { Hash.ruby2_keywords_hash?(nil) }.should raise_error(TypeError)
+    end
+  end
+
+  describe "Hash.ruby2_keywords_hash" do
+    it "returns a copy of a Hash and marks the copy as a keywords Hash" do
+      h = {a: 1}.freeze
+      kw = Hash.ruby2_keywords_hash(h)
+      Hash.ruby2_keywords_hash?(h).should == false
+      Hash.ruby2_keywords_hash?(kw).should == true
+      kw.should == h
+    end
+
+    it "returns an instance of the subclass if called on an instance of a subclass of Hash" do
+      h = HashSpecs::MyHash.new
+      h[:a] = 1
+      kw = Hash.ruby2_keywords_hash(h)
+      kw.class.should == HashSpecs::MyHash
+      Hash.ruby2_keywords_hash?(h).should == false
+      Hash.ruby2_keywords_hash?(kw).should == true
+      kw.should == h
+    end
+
+    it "raises TypeError for non-Hash" do
+      -> { Hash.ruby2_keywords_hash(nil) }.should raise_error(TypeError)
+    end
+  end
+end
diff --git a/spec/ruby/core/kernel/backtick_spec.rb b/spec/ruby/core/kernel/backtick_spec.rb
index 391583b..045bb59 100644
--- a/spec/ruby/core/kernel/backtick_spec.rb
+++ b/spec/ruby/core/kernel/backtick_spec.rb
@@ -36,6 +36,10 @@ describe "Kernel#`" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/backtick_spec.rb#L36
   end
 
   platform_is_not :windows do
+    it "handles invalid UTF-8 bytes in command" do
+      `echo "testing\xC2 a non UTF-8 string"`.should == "testing\xC2 a non UTF-8 string\n"
+    end
+
     it "sets $? to the exit status of the executed sub-process" do
       ip = 'world'
       `echo disc #{ip}`
diff --git a/spec/ruby/core/proc/shared/to_s.rb b/spec/ruby/core/proc/shared/to_s.rb
index 7edd11b..7f167a3 100644
--- a/spec/ruby/core/proc/shared/to_s.rb
+++ b/spec/ruby/core/proc/shared/to_s.rb
@@ -33,8 +33,13 @@ describe :proc_to_s, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/shared/to_s.rb#L33
 
   describe "for a proc created with UnboundMethod#to_proc" do
     it "returns a description including '(lambda)' and optionally including file and line number" do
-      def hello; end
-      method("hello").to_proc.send(@method).should =~ /^#<Proc:([^ ]*?)(#{sep}#{Regexp.escape __FILE__}:#{__LINE__ })? \(lambda\)>$/
+        def hello; end
+        s = method("hello").to_proc.send(@method)
+        if s.include? __FILE__
+          s.should =~ /^#<Proc:([^ ]*?)#{sep}#{Regexp.escape __FILE__}:#{__LINE__ - 3} \(lambda\)>$/
+        else
+          s.should =~ /^#<Proc:([^ ]*?) \(lambda\)>$/
+        end
     end
 
     it "has a binary encoding" do
diff --git a/spec/ruby/core/string/fixtures/classes.rb b/spec/ruby/core/string/fixtures/classes.rb
index 1cc7600..26fcd51 100644
--- a/spec/ruby/core/string/fixtures/classes.rb
+++ b/spec/ruby/core/string/fixtures/classes.rb
@@ -46,4 +46,15 @@ module StringSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/string/fixtures/classes.rb#L46
       self.replace(str)
     end
   end
+
+  class SpecialVarProcessor
+    def process(match)
+      if $~ != nil
+        str = $~[0]
+      else
+        str = "unset"
+      end
+      "<#{str}>"
+    end
+  end
 end
diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb
index 54a2be0..6789199 100644
--- a/spec/ruby/core/string/gsub_spec.rb
+++ b/spec/ruby/core/string/gsub_spec.rb
@@ -475,6 +475,11 @@ describe "String#gsub with pattern and block" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/string/gsub_spec.rb#L475
     offsets.should == [[1, 2], [4, 5]]
   end
 
+  it "does not set $~ for procs created from methods" do
+    str = "hello"
+    str.gsub("l", &StringSpecs::SpecialVarProcessor.new.method(:process)).should == "he<unset><unset>o"
+  end
+
   it "restores $~ after leaving the block" do
     [/./, "l"].each do |pattern|
       old_md = nil
diff --git a/spec/ruby/core/string/unpack/w_spec.rb b/spec/ruby/core/string/unpack/w_spec.rb
index 166ae58..011c75f 100644
--- a/spec/ruby/core/string/unpack/w_spec.rb
+++ b/spec/ruby/core/string/unpack/w_spec.rb
@@ -23,3 +23,13 @@ describe "String#unpack with directive 'w'" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/string/unpack/w_spec.rb#L23
     "\x01\x02\x03".unpack("w w").should == [1, 2]
   end
 end
+
+describe "String#unpack with directive 'w*'" do
+
+  it "decodes BER-compressed integers" do
+    "\x01\x02\x03\x04".unpack("w*").should == [1, 2, 3, 4]
+    "\x00\xCE\x0F\x84\x80\x80\x80\x80\x80\x80\x80\x80\x00\x01\x00".unpack("w*").should == [0, 9999, 2**65, 1, 0]
+    "\x81\x80\x80\x80\x80\x80\x80\x80\x80\x00\x90\x80\x80\x80\x80\x80\x80\x80\x03\x01\x02".unpack("w*").should == [2**63, (2**60 + 3), 1, 2]
+  end
+
+end
diff --git a/spec/ruby/default.mspec b/spec/ruby/default.mspec
index 6fd6d2b..a0dc69c 100644
--- a/spec/ruby/default.mspec
+++ b/spec/ruby/default.mspec
@@ -45,5 +45,6 @@ class MSpecScript https://github.com/ruby/ruby/blob/trunk/spec/ruby/default.mspec#L45
   set :toplevel_constants_excludes, [
     /\wSpecs?$/,
     /^CS_CONST/,
+    /^CSL_CONST/,
   ]
 end
diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb
index 45a8ec5..b2a3cc8 100644
--- a/spec/ruby/language/block_spec.rb
+++ b/spec/ruby/language/block_spec.rb
@@ -873,7 +873,7 @@ describe "Post-args" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/block_spec.rb#L873
     end.call(1, 2, 3).should == [[], 1, 2, 3]
   end
 
-  it "are required" do
+  it "are required for a lambda" do
     -> {
       -> * (... truncated)

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

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