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: b07a5845574d
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a9b4d28c8eeb
Choose a head ref
  • 3 commits
  • 19 files changed
  • 1 contributor

Commits on Mar 27, 2018

  1. Update to ruby/mspec@8b54bf3

    eregon committed Mar 27, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    b838732 View commit details
  2. Update to ruby/spec@a585ec3

    eregon committed Mar 27, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fb1001f View commit details
  3. Add tags for failing specs

    eregon committed Mar 27, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a9b4d28 View commit details
1 change: 1 addition & 0 deletions spec/mspec/lib/mspec/matchers.rb
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
require 'mspec/matchers/have_public_instance_method'
require 'mspec/matchers/have_singleton_method'
require 'mspec/matchers/include'
require 'mspec/matchers/include_any_of'
require 'mspec/matchers/infinity'
require 'mspec/matchers/match_yaml'
require 'mspec/matchers/raise_error'
29 changes: 29 additions & 0 deletions spec/mspec/lib/mspec/matchers/include_any_of.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class IncludeAnyOfMatcher
def initialize(*expected)
@expected = expected
end

def matches?(actual)
@actual = actual
@expected.each do |e|
if @actual.include?(e)
return true
end
end
return false
end

def failure_message
["Expected #{@actual.inspect}", "to include any of #{@expected.inspect}"]
end

def negative_failure_message
["Expected #{@actual.inspect}", "not to include any of #{@expected.inspect}"]
end
end

module MSpecMatchers
private def include_any_of(*expected)
IncludeAnyOfMatcher.new(*expected)
end
end
42 changes: 42 additions & 0 deletions spec/mspec/spec/matchers/include_any_of_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'

describe IncludeAnyOfMatcher do
it "matches when actual includes expected" do
IncludeAnyOfMatcher.new(2).matches?([1,2,3]).should == true
IncludeAnyOfMatcher.new("b").matches?("abc").should == true
end

it "does not match when actual does not include expected" do
IncludeAnyOfMatcher.new(4).matches?([1,2,3]).should == false
IncludeAnyOfMatcher.new("d").matches?("abc").should == false
end

it "matches when actual includes all expected" do
IncludeAnyOfMatcher.new(3, 2, 1).matches?([1,2,3]).should == true
IncludeAnyOfMatcher.new("a", "b", "c").matches?("abc").should == true
end

it "matches when actual includes any expected" do
IncludeAnyOfMatcher.new(3, 4, 5).matches?([1,2,3]).should == true
IncludeAnyOfMatcher.new("c", "d", "e").matches?("abc").should == true
end

it "does not match when actual does not include any expected" do
IncludeAnyOfMatcher.new(4, 5).matches?([1,2,3]).should == false
IncludeAnyOfMatcher.new("de").matches?("abc").should == false
end

it "provides a useful failure message" do
matcher = IncludeAnyOfMatcher.new(5, 6)
matcher.matches?([1,2,3])
matcher.failure_message.should == ["Expected [1, 2, 3]", "to include any of [5, 6]"]
end

it "provides a useful negative failure message" do
matcher = IncludeAnyOfMatcher.new(1, 2, 3)
matcher.matches?([1,2])
matcher.negative_failure_message.should == ["Expected [1, 2]", "not to include any of [1, 2, 3]"]
end
end
3 changes: 1 addition & 2 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",
merge_message: "Update to ruby/spec@",
},
}

@@ -64,7 +63,7 @@ def from_commit
end

def last_merge_message
message = @data[:merge_message] || "Merge ruby/spec commit"
message = @data[:merge_message] || "Update to ruby/spec@"
message.gsub!("ruby/spec", "ruby/mspec") if MSPEC
message
end
12 changes: 12 additions & 0 deletions spec/ruby/core/dir/glob_spec.rb
Original file line number Diff line number Diff line change
@@ -122,6 +122,18 @@
Dir.glob('**/**/**').empty?.should == false
end

it "handles simple filename patterns" do
Dir.glob('.dotfile').should == ['.dotfile']
end

it "handles simple directory patterns" do
Dir.glob('.dotsubdir/').should == ['.dotsubdir/']
end

it "handles simple directory patterns applied to non-directories" do
Dir.glob('nondotfile/').should == []
end

platform_is_not(:windows) do
it "matches the literal character '\\' with option File::FNM_NOESCAPE" do
Dir.mkdir 'foo?bar'
37 changes: 37 additions & 0 deletions spec/ruby/core/enumerator/lazy/uniq_spec.rb
Original file line number Diff line number Diff line change
@@ -3,6 +3,28 @@

ruby_version_is '2.4' do
describe 'Enumerator::Lazy#uniq' do
context 'without block' do
before :each do
@lazy = [0, 1, 0, 1].to_enum.lazy.uniq
end

it 'returns a lazy enumerator' do
@lazy.should be_an_instance_of(Enumerator::Lazy)
@lazy.force.should == [0, 1]
end

ruby_bug "#14495", "2.4"..."2.5.1" do
it 'return same value after rewind' do
@lazy.force.should == [0, 1]
@lazy.force.should == [0, 1]
end
end

it 'sets the size to nil' do
@lazy.size.should == nil
end
end

context 'when yielded with an argument' do
before :each do
@lazy = [0, 1, 2, 3].to_enum.lazy.uniq(&:even?)
@@ -13,6 +35,13 @@
@lazy.force.should == [0, 1]
end

ruby_bug "#14495", "2.4"..."2.5.1" do
it 'return same value after rewind' do
@lazy.force.should == [0, 1]
@lazy.force.should == [0, 1]
end
end

it 'sets the size to nil' do
@lazy.size.should == nil
end
@@ -31,6 +60,14 @@ def each
@lazy = enum.lazy
end

ruby_bug "#14495", "2.4"..."2.5.1" do
it 'return same value after rewind' do
enum = @lazy.uniq { |_, label| label.downcase }
enum.force.should == [[0, 'foo'], [2, 'bar']]
enum.force.should == [[0, 'foo'], [2, 'bar']]
end
end

it 'returns all yield arguments as an array' do
@lazy.uniq { |_, label| label.downcase }.force.should == [[0, 'foo'], [2, 'bar']]
end
8 changes: 4 additions & 4 deletions spec/ruby/core/hash/transform_keys_spec.rb
Original file line number Diff line number Diff line change
@@ -61,21 +61,21 @@
end

# https://bugs.ruby-lang.org/issues/14380
ruby_version_is ""..."2.6" do
ruby_version_is ""..."2.5.1" do
it "does not prevent conflicts between new keys and old ones" do
@hash.transform_keys!(&:succ)
@hash.should == { e: 1 }
end
end

ruby_version_is "2.6" do
ruby_version_is "2.5.1" do
it "prevents conflicts between new keys and old ones" do
@hash.transform_keys!(&:succ)
@hash.should == { b: 1, c: 2, d: 3, e: 4 }
end
end

ruby_version_is ""..."2.6" do
ruby_version_is ""..."2.5.1" do
it "partially modifies the contents if we broke from the block" do
@hash.transform_keys! do |v|
break if v == :c
@@ -85,7 +85,7 @@
end
end

ruby_version_is "2.6" do
ruby_version_is "2.5.1" do
it "returns the processed keys if we broke from the block" do
@hash.transform_keys! do |v|
break if v == :c
2 changes: 1 addition & 1 deletion spec/ruby/core/method/source_location_spec.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file.should be_an_instance_of(String)
file.should == File.dirname(__FILE__) + '/fixtures/classes.rb'
file.should == File.realpath('../fixtures/classes.rb', __FILE__)
end

it "sets the last value to a Fixnum representing the line on which the method was defined" do
14 changes: 14 additions & 0 deletions spec/ruby/core/module/prepend_spec.rb
Original file line number Diff line number Diff line change
@@ -104,6 +104,20 @@ def self.prepend_features(mod)
c.new.alias.should == :m
end

it "reports the class for the owner of an aliased method on the class" do
m = Module.new
c = Class.new { prepend(m); def meth; :c end; alias_method :alias, :meth }
c.instance_method(:alias).owner.should == c
end

ruby_version_is "2.3" do
it "reports the class for the owner of a method aliased from the prepended module" do
m = Module.new { def meth; :m end }
c = Class.new { prepend(m); alias_method :alias, :meth }
c.instance_method(:alias).owner.should == c
end
end

it "sees an instance of a prepended class as kind of the prepended module" do
m = Module.new
c = Class.new { prepend(m) }
43 changes: 43 additions & 0 deletions spec/ruby/core/module/private_spec.rb
Original file line number Diff line number Diff line change
@@ -51,4 +51,47 @@ def foo; end
Module.new.send(:private, :undefined)
end.should raise_error(NameError)
end

ruby_version_is "2.3" do
ruby_bug "#14604", "2.3"..."2.5.1" do
it "only makes the method private in the class it is called on" do
base = Class.new do
def wrapped
1
end
end

klass = Class.new(base) do
def wrapped
super + 1
end
private :wrapped
end

base.new.wrapped.should == 1
lambda do
klass.new.wrapped
end.should raise_error(NameError)
end

it "continues to allow a prepended module method to call super" do
wrapper = Module.new do
def wrapped
super + 1
end
end

klass = Class.new do
prepend wrapper

def wrapped
1
end
private :wrapped
end

klass.new.wrapped.should == 2
end
end
end
end
8 changes: 4 additions & 4 deletions spec/ruby/core/proc/source_location_spec.rb
Original file line number Diff line number Diff line change
@@ -19,19 +19,19 @@
it "sets the first value to the path of the file in which the proc was defined" do
file = @proc.source_location.first
file.should be_an_instance_of(String)
file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)

file = @proc_new.source_location.first
file.should be_an_instance_of(String)
file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)

file = @lambda.source_location.first
file.should be_an_instance_of(String)
file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)

file = @method.source_location.first
file.should be_an_instance_of(String)
file.should == File.dirname(__FILE__) + '/fixtures/source_location.rb'
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
end

it "sets the last value to a Fixnum representing the line on which the proc was defined" do
2 changes: 1 addition & 1 deletion spec/ruby/core/process/spawn_spec.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
code = "STDERR.puts 'hello'"
cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
ruby_exe(cmd, args: "2> #{@output}")
File.binread(@output).should == "hello#{newline}"
File.binread(@output).should =~ /hello#{newline}/
end
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/unboundmethod/source_location_spec.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file.should be_an_instance_of(String)
file.should == File.dirname(__FILE__) + '/fixtures/classes.rb'
file.should == File.realpath('../fixtures/classes.rb', __FILE__)
end

it "sets the last value to a Fixnum representing the line on which the method was defined" do
38 changes: 27 additions & 11 deletions spec/ruby/language/rescue_spec.rb
Original file line number Diff line number Diff line change
@@ -195,18 +195,34 @@ class ArbitraryException < StandardError
ScratchPad.recorded.should == [:one, :else_ran, :ensure_ran, :outside_begin]
end

it "will execute an else block even without rescue and ensure" do
lambda {
eval <<-ruby
begin
ScratchPad << :begin
else
ScratchPad << :else
end
ruby
}.should complain(/else without rescue is useless/)
ruby_version_is ''...'2.6' do
it "will execute an else block even without rescue and ensure" do
lambda {
eval <<-ruby
begin
ScratchPad << :begin
else
ScratchPad << :else
end
ruby
}.should complain(/else without rescue is useless/)

ScratchPad.recorded.should == [:begin, :else]
ScratchPad.recorded.should == [:begin, :else]
end
end

ruby_version_is '2.6' do
it "raises SyntaxError when else is used without rescue and ensure" do
lambda {
eval <<-ruby
begin
ScratchPad << :begin
else
ScratchPad << :else
end
ruby
}.should raise_error(SyntaxError, /else without rescue is useless/)
end
end

it "will not execute an else block if an exception was raised" do
1 change: 1 addition & 0 deletions spec/tags/ruby/core/dir/glob_tags.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@ fails(JRUBY-5667):Dir.glob splits the string on \0 if there is only one string g
fails:Dir.glob raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII
fails:Dir.glob splits the string on \0 if there is only one string given
windows:Dir.glob accepts a block and yields it with each elements
fails:Dir.glob handles simple directory patterns applied to non-directories
3 changes: 3 additions & 0 deletions spec/tags/ruby/core/enumerator/lazy/uniq_tags.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
fails:Enumerator::Lazy#uniq when yielded with multiple arguments returns all yield arguments as an array
fails:Enumerator::Lazy#uniq without block return same value after rewind
fails:Enumerator::Lazy#uniq when yielded with an argument return same value after rewind
fails:Enumerator::Lazy#uniq when yielded with multiple arguments return same value after rewind
1 change: 1 addition & 0 deletions spec/tags/ruby/core/module/prepend_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Module#prepend reports the class for the owner of a method aliased from the prepended module
1 change: 1 addition & 0 deletions spec/tags/ruby/core/module/private_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fails:Module#private without arguments does not affect method definitions when itself is inside an eval and method definitions are outside
fails:Module#private without arguments within a closure sets the visibility outside the closure
fails:Module#private continues to allow a prepended module method to call super
1 change: 1 addition & 0 deletions spec/tags/ruby/core/unboundmethod/owner_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:UnboundMethod#owner returns the new owner for aliased methods on singleton classes