Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf86c33af145
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c911af4b28ab
Choose a head ref
  • 4 commits
  • 31 files changed
  • 1 contributor

Commits on Sep 28, 2017

  1. Squashed 'spec/mspec/' changes from 5bd9409..8aa352c

    8aa352c Have a better error message if #pretty_inspect fails in raise_error message formatting
    c135328 Workaround Travis CI bug
    4a68020 All implementations use spec/ruby as prefix for ruby/spec now
    
    git-subtree-dir: spec/mspec
    git-subtree-split: 8aa352cc7d337f1df74ba66a8d036c4e8973078f
    eregon committed Sep 28, 2017
    Copy the full SHA
    e43c4cc View commit details
  2. Copy the full SHA
    a9fdbdb View commit details
  3. Squashed 'spec/ruby/' changes from a4bc1d8..691755d

    691755d Add spec for String#include? where the search value has an incompatible encoding with the source string.
    d1a080c Add rb_mod_ancestors and spec
    e175126 Remove dead code in Fiber#current spec
    82311d5 MRI bug 1547 has been fixed since 1.9.2
    d405ff6 Fix should === typos in Fiber#current spec
    c62cca0 Add spec for when a Fiber tries to resume itself
    27b9500 Improve error if the IO#select spec fails
    c62f9ba Test standalone -v option less restrictively
    36f668d MRI lazily sorts SortedSet, so we need to force sorting to trigger the errors
    a548109 [spec] SortedSet argument error on adding 'incompatible' elements
    440a92c [spec] improve SortedSet#to_a spec -> we expect sorted contents
    32b2147 check_funcall_missing() should call respond_to_missing?(name, priv=true)
    9cf6780 Prefer adapting specs to complicating library code
    b154f73 Use AV build, update MSYS2 gcc
    5fcba26 Add a couple comments in appveyor.yml
    5875a57 Add ruby24 and trunk to Appveyor, allow_failures for trunk
    cdf6e71 Add spec for Date#year
    32b6ba1 Add spec for Date#month
    b76b5c0 Add spec for Date#day
    5fd5cf9 Add spec for Date#prev_month
    6b5b941 Add spec for Date#prev_day
    bee4eef Add spec for Date#next_month
    e3b6811 Use a simpler comparison
    48e6679 Extract make setup in C ext spec_helper
    c6d0925 Only add "l" in MAKEFLAGS if not already there on Windows
    03ff1ac Fix alignment of preprocessor if
    59c23f1 Use String#casecmp instead of #casecmp? for compatibility in spec_helper
    c6dc781 {Set,SortedSet}#=== is since 2.5
    8e7cce8 Alias Set#=== to #include?
    c75027f rubyspec: jobserver fd may not be available
    5e4f5df rubyspec: use mock directory
    9b9f88b rubyspec: fix types
    4267371 Add spec for Date#next_day (#463)
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 691755de02770a6f67cd8732423afdd8e3f9e710
    eregon committed Sep 28, 2017
    Copy the full SHA
    c3c0595 View commit details
  4. Copy the full SHA
    c911af4 View commit details
Showing with 247 additions and 66 deletions.
  1. +3 −0 spec/mspec/.travis.yml
  2. +7 −1 spec/mspec/lib/mspec/matchers/raise_error.rb
  3. +12 −0 spec/mspec/spec/matchers/raise_error_spec.rb
  4. +1 −3 spec/mspec/tool/sync/sync-rubyspec.rb
  5. +15 −4 spec/ruby/appveyor.yml
  6. +1 −2 spec/ruby/command_line/dash_v_spec.rb
  7. +20 −4 spec/ruby/core/array/flatten_spec.rb
  8. +2 −2 spec/ruby/core/dir/mkdir_spec.rb
  9. +1 −0 spec/ruby/core/io/select_spec.rb
  10. +7 −0 spec/ruby/core/string/include_spec.rb
  11. +4 −1 spec/ruby/library/date/day_spec.rb
  12. +4 −1 spec/ruby/library/date/month_spec.rb
  13. +10 −0 spec/ruby/library/date/next_day_spec.rb
  14. +14 −0 spec/ruby/library/date/next_month_spec.rb
  15. +14 −0 spec/ruby/library/date/prev_day_spec.rb
  16. +14 −0 spec/ruby/library/date/prev_month_spec.rb
  17. +4 −1 spec/ruby/library/date/year_spec.rb
  18. +6 −14 spec/ruby/library/fiber/current_spec.rb
  19. +8 −4 spec/ruby/library/net/ftp/initialize_spec.rb
  20. +9 −0 spec/ruby/library/set/case_equality_spec.rb
  21. +3 −1 spec/ruby/library/set/sortedset/add_spec.rb
  22. +9 −0 spec/ruby/library/set/sortedset/case_equality_spec.rb
  23. +3 −1 spec/ruby/library/set/sortedset/initialize_spec.rb
  24. +4 −4 spec/ruby/optional/capi/ext/fixnum_spec.c
  25. +10 −0 spec/ruby/optional/capi/ext/module_spec.c
  26. +1 −1 spec/ruby/optional/capi/ext/range_spec.c
  27. +1 −0 spec/ruby/optional/capi/ext/rubyspec.h
  28. +19 −8 spec/ruby/optional/capi/ext/st_spec.c
  29. +10 −0 spec/ruby/optional/capi/module_spec.rb
  30. +26 −14 spec/ruby/optional/capi/spec_helper.rb
  31. +5 −0 spec/ruby/shared/fiber/resume.rb
3 changes: 3 additions & 0 deletions spec/mspec/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
sudo: false
language: ruby
before_script:
# https://github.com/travis-ci/travis-ci/issues/8408
- unset _JAVA_OPTIONS
script:
- bundle exec rspec
matrix:
8 changes: 7 additions & 1 deletion spec/mspec/lib/mspec/matchers/raise_error.rb
Original file line number Diff line number Diff line change
@@ -53,13 +53,19 @@ def format_exception(exception)
exception_class_and_message(exception.class, exception.message)
end

def format_result(result)
result.pretty_inspect.chomp
rescue => e
"#pretty_inspect raised #{e.class}; A #<#{result.class}>"
end

def failure_message
message = ["Expected #{format_expected_exception}"]

if @actual
message << "but got #{format_exception(@actual)}"
else
message << "but no exception was raised (#{@result.pretty_inspect.chomp} was returned)"
message << "but no exception was raised (#{format_result(@result)} was returned)"
end

message
12 changes: 12 additions & 0 deletions spec/mspec/spec/matchers/raise_error_spec.rb
Original file line number Diff line number Diff line change
@@ -90,6 +90,18 @@ class UnexpectedException < Exception; end
["Expected ExpectedException (expected)", "but no exception was raised (nil was returned)"]
end

it "provides a useful failure message when no exception is raised and the result raises in #pretty_inspect" do
result = Object.new
def result.pretty_inspect
raise ArgumentError, "bad"
end
proc = Proc.new { result }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
matcher.failure_message.should ==
["Expected ExpectedException (expected)", "but no exception was raised (#pretty_inspect raised ArgumentError; A #<Object> was returned)"]
end

it "provides a useful negative failure message" do
proc = Proc.new { raise ExpectedException, "expected" }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
4 changes: 1 addition & 3 deletions spec/mspec/tool/sync/sync-rubyspec.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
mri: {
git: "https://github.com/ruby/ruby.git",
master: "trunk",
prefix: "spec/rubyspec",
merge_message: "Update to ruby/spec@",
},
}
@@ -71,8 +70,7 @@ def last_merge_message
end

def prefix
return "spec/mspec" if MSPEC
@data[:prefix] || "spec/ruby"
MSPEC ? "spec/mspec" : "spec/ruby"
end

def rebased_branch
19 changes: 15 additions & 4 deletions spec/ruby/appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
---
version: "{build}"
clone_depth: 5
init:
# To avoid duplicated executables in PATH, see https://github.com/ruby/spec/pull/468
- set PATH=C:\ruby%RUBY_VERSION%\bin;C:\Program Files\7-Zip;C:\Program Files\AppVeyor\BuildAgent;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Program Files;C:\Windows
# Loads trunk build and updates MSYS2 / MinGW to most recent gcc compiler
- if %ruby_version%==_trunk (
appveyor DownloadFile https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z -FileName C:\ruby_trunk.7z &
7z x C:\ruby_trunk.7z -oC:\ruby_trunk & C:\ruby_trunk\trunk_msys2.cmd)
environment:
matrix:
- RUBY_VERSION: 23-x64
- RUBY_VERSION: 24-x64
- RUBY_VERSION: _trunk # So the folder name is ruby_trunk
install:
- SET PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
- ruby --version
- call "C:\Ruby23-x64\DevKit\devkitvars.bat"
- git clone https://github.com/ruby/mspec.git ../mspec
build: off
test_script:
- SET CHECK_LEAKS=true
- ../mspec/bin/mspec -ff
- ../mspec/bin/mspec -rdevkit -ff
on_finish:
- ruby -v
matrix:
allow_failures:
- ruby_version: _trunk
branches:
only:
- master
3 changes: 1 addition & 2 deletions spec/ruby/command_line/dash_v_spec.rb
Original file line number Diff line number Diff line change
@@ -6,8 +6,7 @@

describe "when used alone" do
it "prints version and ends" do
version = ruby_exe(nil, args: '--version')
ruby_exe(nil, args: '-v').should == version
ruby_exe(nil, args: '-v').include?(RUBY_DESCRIPTION).should == true
end
end
end
24 changes: 20 additions & 4 deletions spec/ruby/core/array/flatten_spec.rb
Original file line number Diff line number Diff line change
@@ -111,18 +111,34 @@
lambda { [@obj].flatten }.should raise_error(TypeError)
end

ruby_version_is ""..."2.5" do
it "calls respond_to_missing?(:to_ary, false) to try coercing" do
def @obj.respond_to_missing?(*args) ScratchPad << args; false end
[@obj].flatten.should == [@obj]
ScratchPad.recorded.should == [[:to_ary, false]]
end
end

ruby_version_is "2.5" do
it "calls respond_to_missing?(:to_ary, true) to try coercing" do
def @obj.respond_to_missing?(*args) ScratchPad << args; false end
[@obj].flatten.should == [@obj]
ScratchPad.recorded.should == [[:to_ary, true]]
end
end

it "does not call #to_ary if not defined when #respond_to_missing? returns false" do
def @obj.respond_to_missing?(*args) ScratchPad << args; false end
def @obj.respond_to_missing?(name, priv) ScratchPad << name; false end

[@obj].flatten.should == [@obj]
ScratchPad.recorded.should == [[:to_ary, false]]
ScratchPad.recorded.should == [:to_ary]
end

it "calls #to_ary if not defined when #respond_to_missing? returns true" do
def @obj.respond_to_missing?(*args) ScratchPad << args; true end
def @obj.respond_to_missing?(name, priv) ScratchPad << name; true end

lambda { [@obj].flatten }.should raise_error(NoMethodError)
ScratchPad.recorded.should == [[:to_ary, false]]
ScratchPad.recorded.should == [:to_ary]
end

it "calls #method_missing if defined" do
4 changes: 2 additions & 2 deletions spec/ruby/core/dir/mkdir_spec.rb
Original file line number Diff line number Diff line change
@@ -55,11 +55,11 @@
end

it "raises Errno::EEXIST if the specified directory already exists" do
lambda { Dir.mkdir(File.dirname(__FILE__)) }.should raise_error(Errno::EEXIST)
lambda { Dir.mkdir("#{DirSpecs.mock_dir}/dir") }.should raise_error(Errno::EEXIST)
end

it "raises Errno::EEXIST if the argument points to the existing file" do
lambda { Dir.mkdir(__FILE__) }.should raise_error(Errno::EEXIST)
lambda { Dir.mkdir("#{DirSpecs.mock_dir}/file_one.ext") }.should raise_error(Errno::EEXIST)
end
end

1 change: 1 addition & 0 deletions spec/ruby/core/io/select_spec.rb
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@
end

Thread.pass while t.status && t.status != "sleep"
t.join unless t.status
t.status.should == "sleep"
t.kill
t.join
7 changes: 7 additions & 0 deletions spec/ruby/core/string/include_spec.rb
Original file line number Diff line number Diff line change
@@ -25,4 +25,11 @@
lambda { "hello".include?('h'.ord) }.should raise_error(TypeError)
lambda { "hello".include?(mock('x')) }.should raise_error(TypeError)
end

it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
pat = "ア".encode Encoding::EUC_JP
lambda do
"あれ".include?(pat)
end.should raise_error(Encoding::CompatibilityError)
end
end
5 changes: 4 additions & 1 deletion spec/ruby/library/date/day_spec.rb
Original file line number Diff line number Diff line change
@@ -2,5 +2,8 @@
require 'date'

describe "Date#day" do
it "needs to be reviewed for spec completeness"
it "returns the day" do
d = Date.new(2000, 7, 1).day
d.should == 1
end
end
5 changes: 4 additions & 1 deletion spec/ruby/library/date/month_spec.rb
Original file line number Diff line number Diff line change
@@ -2,5 +2,8 @@
require 'date'

describe "Date#month" do
it "needs to be reviewed for spec completeness"
it "returns the month" do
m = Date.new(2000, 7, 1).month
m.should == 7
end
end
10 changes: 10 additions & 0 deletions spec/ruby/library/date/next_day_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'

describe "Date#next_day" do
it "returns the next day" do
d = Date.new(2000, 1, 5)
d1 = Date.new(2000, 1, 4).next_day
d1.should == d
end
end
14 changes: 14 additions & 0 deletions spec/ruby/library/date/next_month_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'

describe "Date#next_month" do
it "returns the next month" do
d = Date.new(2000, 7, 1).next_month
d.should == Date.new(2000, 8, 1)
end

it "returns three months later" do
d = Date.new(2000, 7, 1).next_month(3)
d.should == Date.new(2000, 10, 1)
end
end
14 changes: 14 additions & 0 deletions spec/ruby/library/date/prev_day_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'

describe "Date#prev_day" do
it "returns previous day" do
d = Date.new(2000, 7, 2).prev_day
d.should == Date.new(2000, 7, 1)
end

it "returns three days ago" do
d = Date.new(2000, 7, 4).prev_day(3)
d.should == Date.new(2000, 7, 1)
end
end
14 changes: 14 additions & 0 deletions spec/ruby/library/date/prev_month_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'

describe "Date#prev_month" do
it "returns previous month" do
d = Date.new(2000, 9, 1).prev_month
d.should == Date.new(2000, 8, 1)
end

it "returns three months ago" do
d = Date.new(2000, 10, 1).prev_month(3)
d.should == Date.new(2000, 7, 1)
end
end
5 changes: 4 additions & 1 deletion spec/ruby/library/date/year_spec.rb
Original file line number Diff line number Diff line change
@@ -2,5 +2,8 @@
require 'date'

describe "Date#year" do
it "needs to be reviewed for spec completeness"
it "returns the year" do
y = Date.new(2000, 7, 1).year
y.should == 2000
end
end
20 changes: 6 additions & 14 deletions spec/ruby/library/fiber/current_spec.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
# We can always transfer to the root Fiber; it will never die
5.times do
root.transfer.should be_nil
root.alive?.should_not be_false #Workaround for bug #1547
root.alive?.should be_true
end
end

@@ -19,39 +19,31 @@
this = Fiber.current
this.should be_an_instance_of(Fiber)
this.should == fiber
this.alive?.should_not be_false # Workaround for bug #1547
this.alive?.should be_true
end
fiber.resume
end

it "returns the current Fiber when called from a Fiber that transferred to another" do

states = []
fiber = Fiber.new do
states << :fiber
this = Fiber.current
this.should be_an_instance_of(Fiber)
this.should === fiber
this.alive?.should_not be_false # Workaround for bug #1547
this.should == fiber
this.alive?.should be_true
end

fiber2 = Fiber.new do
states << :fiber2
fiber.transfer
this = Fiber.current
this.should be_an_instance_of(Fiber)
this.should === fiber2
this.alive?.should_not be_false # Workaround for bug #1547
flunk
end

fiber3 = Fiber.new do
states << :fiber3
fiber2.transfer
this = Fiber.current
this.should be_an_instance_of(Fiber)
this.should === fiber3
this.alive?.should_not be_false # Workaround for bug #1547
fiber2.transfer
flunk
end

fiber3.resume
12 changes: 8 additions & 4 deletions spec/ruby/library/net/ftp/initialize_spec.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@
before :each do
@ftp = Net::FTP.allocate
@ftp.stub!(:connect)
@port_args = []
ruby_version_is "2.5" do
@port_args << 21
end
end

it "is private" do
@@ -44,14 +48,14 @@

describe "when passed host" do
it "tries to connect to the passed host" do
@ftp.should_receive(:connect).with("localhost")
@ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end
end

describe "when passed host, user" do
it "tries to connect to the passed host" do
@ftp.should_receive(:connect).with("localhost")
@ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end

@@ -63,7 +67,7 @@

describe "when passed host, user, password" do
it "tries to connect to the passed host" do
@ftp.should_receive(:connect).with("localhost")
@ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end

@@ -75,7 +79,7 @@

describe "when passed host, user" do
it "tries to connect to the passed host" do
@ftp.should_receive(:connect).with("localhost")
@ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end

9 changes: 9 additions & 0 deletions spec/ruby/library/set/case_equality_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/include', __FILE__)
require 'set'

ruby_version_is "2.5" do
describe "Set#===" do
it_behaves_like :set_include, :===
end
end
4 changes: 3 additions & 1 deletion spec/ruby/library/set/sortedset/add_spec.rb
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@
end

it "raises on incompatible <=> comparison" do
lambda { SortedSet['1', '2'].add(3) }.should raise_error(ArgumentError)
# Use #to_a here as elements are sorted only when needed.
# Therefore the <=> incompatibility is only noticed on sorting.
lambda { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
end
end

Loading