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

ruby-changes:60227

From: Benoit <ko1@a...>
Date: Sat, 29 Feb 2020 03:08:01 +0900 (JST)
Subject: [ruby-changes:60227] a0f5ff4c3c (master): Update to ruby/spec@41bf282

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

From a0f5ff4c3cd05f8717be2bf1d79f0817f288d398 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Fri, 28 Feb 2020 19:07:17 +0100
Subject: Update to ruby/spec@41bf282


diff --git a/spec/ruby/CONTRIBUTING.md b/spec/ruby/CONTRIBUTING.md
index 1ec6f0f..d092486 100644
--- a/spec/ruby/CONTRIBUTING.md
+++ b/spec/ruby/CONTRIBUTING.md
@@ -53,6 +53,8 @@ which indicates the file was generated but the method unspecified. https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L53
 Here is a list of frequently-used matchers, which should be enough for most specs.
 There are a few extra specific matchers used in the couple specs that need it.
 
+#### Comparison matchers
+
 ```ruby
 (1 + 2).should == 3 # Calls #==
 (1 + 2).should_not == 5
@@ -66,7 +68,11 @@ File.should equal(File) # Calls #equal? (tests identity) https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L68
 4.should > 3
 
 "Hello".should =~ /l{2}/ # Calls #=~ (Regexp match)
+```
 
+#### Predicate matchers
+
+```ruby
 [].should be_empty # Calls #empty?
 [1,2,3].should include(2) # Calls #include?
 
@@ -82,8 +88,13 @@ Numeric.should be_ancestor_of(Float) # Float.ancestors.include?(Numeric) https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L88
 3.14.should respond_to(:to_i) # Calls #respond_to?
 Fixnum.should have_instance_method(:+)
 Array.should have_method(:new)
-# Also have_constant, have_private_instance_method, have_singleton_method, etc
+```
+
+Also `have_constant`, `have_private_instance_method`, `have_singleton_method`, etc.
 
+#### Exception matchers
+
+```ruby
 -> {
   raise "oops"
 }.should raise_error(RuntimeError, /oops/)
@@ -95,11 +106,20 @@ Array.should have_method(:new) https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L106
   e.message.should include("oops")
   e.cause.should == nil
 }
+```
+
+##### should_not raise_error
 
-# To avoid! Instead, use an expectation testing what the code in the lambda does.
-# If an exception is raised, it will fail the example anyway.
+**To avoid!** Instead, use an expectation testing what the code in the lambda does.
+If an exception is raised, it will fail the example anyway.
+
+```ruby
 -> { ... }.should_not raise_error
+```
+
+#### Warning matcher
 
+```ruby
 -> {
   Fixnum
 }.should complain(/constant ::Fixnum is deprecated/) # Expect a warning
@@ -110,6 +130,8 @@ Array.should have_method(:new) https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L130
 Different guards are available as defined by mspec.
 Here is a list of the most commonly-used guards:
 
+#### Version guards
+
 ```ruby
 ruby_version_is ""..."2.4" do
   # Specs for RUBY_VERSION < 2.4
@@ -118,7 +140,11 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L140
 ruby_version_is "2.4" do
   # Specs for RUBY_VERSION >= 2.4
 end
+```
 
+#### Platform guards
+
+```ruby
 platform_is :windows do
   # Specs only valid on Windows
 end
@@ -140,18 +166,25 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L166
 big_endian do
   # Big-endian platform
 end
+```
+
+#### Guard for bug
+
+In case there is a bug in MRI but the expected behavior is obvious.
+First, file a bug at https://bugs.ruby-lang.org/.
+It is better to use a `ruby_version_is` guard if there was a release with the fix.
 
-# In case there is a bug in MRI but the expected behavior is obvious
-# First file a bug at https://bugs.ruby-lang.org/
-# It is better to use a ruby_version_is guard if there was a release with the fix
+```ruby
 ruby_bug '#13669', ''...'2.5' do
   it "works like this" do
     # Specify the expected behavior here, not the bug
   end
 end
+```
 
+#### Combining guards
 
-# Combining guards
+```ruby
 guard -> { platform_is :windows and ruby_version_is ""..."2.5" } do
   # Windows and RUBY_VERSION < 2.5
 end
@@ -159,8 +192,11 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L192
 guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
   # The opposite
 end
+```
 
-# Custom guard
+#### Custom guard
+
+```ruby
 max_uint = (1 << 32) - 1
 guard -> { max_uint <= fixnum_max } do
 end
@@ -168,6 +204,8 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L204
 
 Custom guards are better than a simple `if` as they allow [mspec commands](https://github.com/ruby/mspec/issues/30#issuecomment-312487779) to work properly.
 
+#### Implementation-specific behaviors
+
 In general, the usage of guards should be minimized as possible.
 
 There are no guards to define implementation-specific behavior because
diff --git a/spec/ruby/README.md b/spec/ruby/README.md
index b34e668..e6c7153 100644
--- a/spec/ruby/README.md
+++ b/spec/ruby/README.md
@@ -1,7 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/README.md#L1
 # The Ruby Spec Suite
 
-[![Actions Build Status](https://github.com/ruby/spec/workflows/CI/badge.svg?branch=master)](https://github.com/ruby/spec/actions)
-[![Windows Actions Build Status](https://github.com/ruby/spec/workflows/Windows/badge.svg?branch=master)](https://github.com/ruby/spec/actions)
+[![Actions Build Status](https://github.com/ruby/spec/workflows/CI/badge.svg)](https://github.com/ruby/spec/actions)
 [![Gitter](https://badges.gitter.im/ruby/spec.svg)](https://gitter.im/ruby/spec)
 
 The Ruby Spec Suite, abbreviated `ruby/spec`, is a test suite for the behavior of the Ruby programming language.
diff --git a/spec/ruby/command_line/dash_l_spec.rb b/spec/ruby/command_line/dash_l_spec.rb
new file mode 100644
index 0000000..51d924e
--- /dev/null
+++ b/spec/ruby/command_line/dash_l_spec.rb
@@ -0,0 +1,33 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_l_spec.rb#L1
+require_relative '../spec_helper'
+
+describe "The -l command line option" do
+  before :each do
+    @names  = fixture __FILE__, "full_names.txt"
+  end
+
+  it "chomps lines with default separator" do
+    ruby_exe('puts $_.end_with?("\n")', options: "-n -l", escape: true,
+             args: " < #{@names}").should ==
+        "false\nfalse\nfalse\n"
+  end
+
+  ruby_version_is "2.5" do
+    it "chomps last line based on $/" do
+      ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", escape: true,
+               args: " < #{@names}").should ==
+          "alice j\nbob field\njames grey\n"
+    end
+  end
+
+  it "sets $\\ to the value of $/" do
+    ruby_exe("puts $\\ == $/", options: "-W0 -n -l", escape: true,
+             args: " < #{@names}").should ==
+        "true\ntrue\ntrue\n"
+  end
+
+  it "sets $-l" do
+    ruby_exe("puts $-l", options: "-n -l", escape: true,
+                         args: " < #{@names}").should ==
+      "true\ntrue\ntrue\n"
+  end
+end
diff --git a/spec/ruby/core/array/shared/slice.rb b/spec/ruby/core/array/shared/slice.rb
index 1e7fdf9..d6b4547 100644
--- a/spec/ruby/core/array/shared/slice.rb
+++ b/spec/ruby/core/array/shared/slice.rb
@@ -461,7 +461,7 @@ describe :array_slice, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/slice.rb#L461
   it "raises a RangeError when the start index is out of range of Fixnum" do
     array = [1, 2, 3, 4, 5, 6]
     obj = mock('large value')
-    obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
+    obj.should_receive(:to_int).and_return(bignum_value)
     -> { array.send(@method, obj) }.should raise_error(RangeError)
 
     obj = 8e19
@@ -471,10 +471,19 @@ describe :array_slice, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/slice.rb#L471
   it "raises a RangeError when the length is out of range of Fixnum" do
     array = [1, 2, 3, 4, 5, 6]
     obj = mock('large value')
-    obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
+    obj.should_receive(:to_int).and_return(bignum_value)
     -> { array.send(@method, 1, obj) }.should raise_error(RangeError)
 
     obj = 8e19
     -> { array.send(@method, 1, obj) }.should raise_error(RangeError)
   end
+
+  it "raises a type error if a range is passed with a length" do
+    ->{ [1, 2, 3].send(@method, 1..2, 1) }.should raise_error(TypeError)
+  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)
+  end
 end
diff --git a/spec/ruby/core/binding/eval_spec.rb b/spec/ruby/core/binding/eval_spec.rb
index 84096f8..224bce4 100644
--- a/spec/ruby/core/binding/eval_spec.rb
+++ b/spec/ruby/core/binding/eval_spec.rb
@@ -131,4 +131,10 @@ describe "Binding#eval" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/binding/eval_spec.rb#L131
     bind, meth = obj.get_binding_with_send_and_method
     bind.eval("__method__").should == meth
   end
+
+  it "reflects refinements activated in the binding scope" do
+    bind = BindingSpecs::Refined.refined_binding
+
+    bind.eval("'bar'.foo").should == "foo"
+  end
 end
diff --git a/spec/ruby/core/binding/fixtures/classes.rb b/spec/ruby/core/binding/fixtures/classes.rb
index 43e32ca..b5f3ce9 100644
--- a/spec/ruby/core/binding/fixtures/classes.rb
+++ b/spec/ruby/core/binding/fixtures/classes.rb
@@ -49,4 +49,18 @@ module BindingSpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/binding/fixtures/classes.rb#L49
       end
     end
   end
+
+  module AddFooToString
+    refine(String) do
+      def foo
+        "foo"
+      end
+    end
+  end
+  class Refined
+    using AddFooToString
+    def self.refined_binding
+      binding
+    end
+  end
 end
diff --git a/spec/ruby/core/file/realpath_spec.rb b/spec/ruby/core/file/realpath_spec.rb
index 0c5d192..bd27e09 100644
--- a/spec/ruby/core/file/realpath_spec.rb
+++ b/spec/ruby/core/file/realpath_spec.rb
@@ -67,6 +67,12 @@ platform_is_not :windows do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/realpath_spec.rb#L67
     it "raises Errno::ENOENT if t (... truncated)

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

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