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

Commits on Feb 27, 2018

  1. Update to ruby/mspec@d287466

    eregon committed Feb 27, 2018
    Copy the full SHA
    54eebf8 View commit details
  2. Update to ruby/spec@cbe855c

    eregon committed Feb 27, 2018
    Copy the full SHA
    debc0d1 View commit details
Showing with 458 additions and 312 deletions.
  1. +1 −1 spec/mspec/.travis.yml
  2. +18 −0 spec/mspec/tool/pull-latest-mspec-spec
  3. +1 −12 spec/mspec/tool/sync/sync-rubyspec.rb
  4. +2 −0 spec/ruby/CONTRIBUTING.md
  5. +3 −3 spec/ruby/README.md
  6. +25 −0 spec/ruby/command_line/dash_upper_e_spec.rb
  7. +1 −2 spec/ruby/core/array/clear_spec.rb
  8. +1 −1 spec/ruby/core/array/compact_spec.rb
  9. +16 −0 spec/ruby/core/array/filter_spec.rb
  10. +2 −2 spec/ruby/core/array/reject_spec.rb
  11. +2 −24 spec/ruby/core/array/select_spec.rb
  12. +2 −2 spec/ruby/core/array/shared/clone.rb
  13. +2 −2 spec/ruby/core/array/shared/collect.rb
  14. +32 −0 spec/ruby/core/array/shared/select.rb
  15. +24 −16 spec/ruby/core/encoding/converter/last_error_spec.rb
  16. +10 −21 spec/ruby/core/encoding/default_external_spec.rb
  17. +0 −17 spec/ruby/core/encoding/default_internal_spec.rb
  18. +9 −0 spec/ruby/core/enumerable/filter_spec.rb
  19. +1 −1 spec/ruby/core/env/shared/to_hash.rb
  20. +1 −1 spec/ruby/core/exception/no_method_error_spec.rb
  21. +1 −1 spec/ruby/core/file/shared/path.rb
  22. +1 −1 spec/ruby/core/hash/clone_spec.rb
  23. +1 −1 spec/ruby/core/hash/compare_by_identity_spec.rb
  24. +12 −0 spec/ruby/core/hash/filter_spec.rb
  25. +3 −76 spec/ruby/core/hash/select_spec.rb
  26. +91 −0 spec/ruby/core/hash/shared/select.rb
  27. +2 −2 spec/ruby/core/io/read_spec.rb
  28. +1 −1 spec/ruby/core/kernel/Float_spec.rb
  29. +25 −7 spec/ruby/core/kernel/Integer_spec.rb
  30. +6 −0 spec/ruby/core/matchdata/inspect_spec.rb
  31. +4 −4 spec/ruby/core/proc/block_pass_spec.rb
  32. +1 −2 spec/ruby/core/process/groups_spec.rb
  33. +2 −2 spec/ruby/core/process/times_spec.rb
  34. +2 −2 spec/ruby/core/{struct → process}/tms/cstime_spec.rb
  35. +2 −2 spec/ruby/core/{struct → process}/tms/cutime_spec.rb
  36. +1 −1 spec/ruby/core/{struct → process}/tms/element_reference_spec.rb
  37. +1 −1 spec/ruby/core/{struct → process}/tms/members_spec.rb
  38. +1 −1 spec/ruby/core/{struct → process}/tms/new_spec.rb
  39. +2 −2 spec/ruby/core/{struct → process}/tms/stime_spec.rb
  40. +2 −2 spec/ruby/core/{struct → process}/tms/utime_spec.rb
  41. +1 −1 spec/ruby/core/string/chr_spec.rb
  42. +1 −1 spec/ruby/core/string/clear_spec.rb
  43. +2 −3 spec/ruby/core/string/freeze_spec.rb
  44. +1 −1 spec/ruby/core/time/at_spec.rb
  45. +1 −1 spec/ruby/core/time/succ_spec.rb
  46. +2 −2 spec/ruby/language/defined_spec.rb
  47. +3 −3 spec/ruby/language/predefined_spec.rb
  48. +1 −1 spec/ruby/library/csv/generate_spec.rb
  49. +2 −1 spec/ruby/library/erb/defmethod/def_erb_method_spec.rb
  50. +9 −0 spec/ruby/library/erb/fixtures/classes.rb
  51. +19 −13 spec/ruby/library/erb/new_spec.rb
  52. +8 −0 spec/ruby/library/set/filter_spec.rb
  53. +2 −38 spec/ruby/library/set/select_spec.rb
  54. +42 −0 spec/ruby/library/set/shared/select.rb
  55. +9 −0 spec/ruby/library/set/sortedset/filter_spec.rb
  56. +2 −30 spec/ruby/library/set/sortedset/select_spec.rb
  57. +35 −0 spec/ruby/library/set/sortedset/shared/select.rb
  58. +2 −2 spec/ruby/optional/capi/gc_spec.rb
  59. +2 −2 spec/ruby/optional/capi/string_spec.rb
2 changes: 1 addition & 1 deletion spec/mspec/.travis.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,6 @@ matrix:
- gem update --system
- jdk: oraclejdk8
install:
- curl -L https://github.com/graalvm/truffleruby/releases/download/vm-enterprise-0.28/truffleruby-testing-0.28.tar.gz | tar xz
- curl -L https://github.com/oracle/truffleruby/releases/download/vm-enterprise-0.28/truffleruby-testing-0.28.tar.gz | tar xz
- source truffleruby/setup_env
- bundle install
18 changes: 18 additions & 0 deletions spec/mspec/tool/pull-latest-mspec-spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Assumes all commits have been synchronized to https://github.com/ruby/spec
# See spec/mspec/tool/sync/sync-rubyspec.rb

rm -rf spec/mspec
git clone --depth 1 https://github.com/ruby/mspec.git spec/mspec
commit=$(git -C spec/mspec log -n 1 --format='%h')
rm -rf spec/mspec/.git
git add spec/mspec
git commit -m "Update to ruby/mspec@${commit}"

rm -rf spec/ruby
git clone --depth 1 https://github.com/ruby/spec.git spec/ruby
commit=$(git -C spec/ruby log -n 1 --format='%h')
rm -rf spec/ruby/.git
git add spec/ruby
git commit -m "Update to ruby/spec@${commit}"
13 changes: 1 addition & 12 deletions spec/mspec/tool/sync/sync-rubyspec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
IMPLS = {
truffleruby: {
git: "https://github.com/graalvm/truffleruby.git",
git: "https://github.com/oracle/truffleruby.git",
from_commit: "f10ab6988d",
},
jruby: {
@@ -182,17 +182,6 @@ def test_new_specs
def verify_commits(impl)
puts
Dir.chdir(SOURCE_REPO) do
history = `git log master...`
history.lines.slice_before(/^commit \h{40}$/).each do |commit, *message|
commit = commit.chomp.split.last
message = message.join
if /\W(#\d+)/ === message
puts "Commit #{commit} contains an unqualified issue number: #{$1}"
puts "Replace it with #{impl.repo_org}/#{impl.repo_name}#{$1}"
sh "git", "rebase", "-i", "#{commit}^"
end
end

puts "Manually check commit messages:"
print "Press enter >"
STDIN.gets
2 changes: 2 additions & 0 deletions spec/ruby/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -158,6 +158,8 @@ guard -> { max_uint <= fixnum_max } do
end
```

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.

In general, the usage of guards should be minimized as possible.

There are no guards to define implementation-specific behavior because
6 changes: 3 additions & 3 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
@@ -24,9 +24,9 @@ The language specs are grouped by keyword while the core and standard library sp

ruby/spec is known to be tested in these implementations for every commit:
* [MRI](http://rubyci.org/) on 30 platforms and 4 versions
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) on Travis for both 1.7 and 9.x
* [TruffleRuby](https://github.com/graalvm/truffleruby) on Travis
* [Opal](https://github.com/opal/opal/tree/master/spec) on Travis
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
* [TruffleRuby](https://github.com/oracle/truffleruby)
* [Opal](https://github.com/opal/opal/tree/master/spec)

ruby/spec describes the behavior of Ruby 2.2 and more recent Ruby versions.
More precisely, every latest stable MRI release [passes](https://rubyci.org/) all specs of ruby/spec
25 changes: 25 additions & 0 deletions spec/ruby/command_line/dash_upper_e_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
describe "ruby -E" do
it "sets the external encoding with '-E external'" do
result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
result.should == "EUC-JP"
end

it "also sets the filesystem encoding with '-E external'" do
result = ruby_exe("print Encoding.find('filesystem')", options: '-E euc-jp')
result.should == "EUC-JP"
end

it "sets the external encoding with '-E external:'" do
result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
result.should == "Shift_JIS"
end

it "sets the internal encoding with '-E :internal'" do
ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
should == 'Shift_JIS'
end

it "sets the external and internal encodings with '-E external:internal'" do
ruby_exe("puts Encoding.default_external, Encoding.default_internal", options: '-E euc-jp:SHIFT_JIS').
should == "EUC-JP\nShift_JIS\n"
end

it "raises a RuntimeError if used with -U" do
ruby_exe("p 1",
options: '-Eascii:ascii -U',
3 changes: 1 addition & 2 deletions spec/ruby/core/array/clear_spec.rb
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@

it "returns self" do
a = [1]
oid = a.object_id
a.clear.object_id.should == oid
a.should equal a.clear
end

it "leaves the Array empty" do
2 changes: 1 addition & 1 deletion spec/ruby/core/array/compact_spec.rb
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@

it "returns self if some nil elements are removed" do
a = ['a', nil, 'b', false, 'c']
a.compact!.object_id.should == a.object_id
a.compact!.should equal a
end

it "returns nil if there are no nil elements to remove" do
16 changes: 16 additions & 0 deletions spec/ruby/core/array/filter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/select', __FILE__)

ruby_version_is "2.6" do
describe "Array#filter" do
it_behaves_like :array_select, :filter
end

describe "Array#filter!" do
it "returns nil if no changes were made in the array" do
[1, 2, 3].filter! { true }.should be_nil
end

it_behaves_like :keep_if, :filter!
end
end
4 changes: 2 additions & 2 deletions spec/ruby/core/array/reject_spec.rb
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@
ary = [1, 2, 3, 4, 5]
ary.reject { true }.should == []
ary.reject { false }.should == ary
ary.reject { false }.object_id.should_not == ary.object_id
ary.reject { false }.should_not equal ary
ary.reject { nil }.should == ary
ary.reject { nil }.object_id.should_not == ary.object_id
ary.reject { nil }.should_not equal ary
ary.reject { 5 }.should == []
ary.reject { |i| i < 3 }.should == [3, 4, 5]
ary.reject { |i| i % 2 == 0 }.should == [1, 3, 5]
26 changes: 2 additions & 24 deletions spec/ruby/core/array/select_spec.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/enumeratorize', __FILE__)
require File.expand_path('../shared/keep_if', __FILE__)
require File.expand_path('../../enumerable/shared/enumeratorized', __FILE__)
require File.expand_path('../shared/select', __FILE__)

describe "Array#select" do
it_behaves_like :enumeratorize, :select
it_behaves_like :enumeratorized_with_origin_size, :select, [1,2,3]

it "returns a new array of elements for which block is true" do
[1, 3, 4, 5, 6, 9].select { |i| i % ((i + 1) / 2) == 0}.should == [1, 4, 6]
end

it "does not return subclass instance on Array subclasses" do
ArraySpecs::MyArray[1, 2, 3].select { true }.should be_an_instance_of(Array)
end

it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty.select { true }.should == empty
empty.select { false }.should == []

array = ArraySpecs.recursive_array
array.select { true }.should == [1, 'two', 3.0, array, array, array, array, array]
array.select { false }.should == []
end
it_behaves_like :array_select, :select
end

describe "Array#select!" do
4 changes: 2 additions & 2 deletions spec/ruby/core/array/shared/clone.rb
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
it "produces a shallow copy where the references are directly copied" do
a = [mock('1'), mock('2')]
b = a.send @method
b.first.object_id.should == a.first.object_id
b.last.object_id.should == a.last.object_id
b.first.should equal a.first
b.last.should equal a.last
end

it "creates a new array containing all elements or the original" do
4 changes: 2 additions & 2 deletions spec/ruby/core/array/shared/collect.rb
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
a = ['a', 'b', 'c', 'd']
b = a.send(@method) { |i| i + '!' }
b.should == ["a!", "b!", "c!", "d!"]
b.object_id.should_not == a.object_id
b.should_not equal a
end

it "does not return subclass instance" do
@@ -70,7 +70,7 @@
it "returns self" do
a = [1, 2, 3, 4, 5]
b = a.send(@method) {|i| i+1 }
a.object_id.should == b.object_id
a.should equal b
end

it "returns the evaluated value of block but its contents is partially modified, if it broke in the block" do
32 changes: 32 additions & 0 deletions spec/ruby/core/array/shared/select.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
require File.expand_path('../../shared/enumeratorize', __FILE__)
require File.expand_path('../../shared/keep_if', __FILE__)
require File.expand_path('../../../enumerable/shared/enumeratorized', __FILE__)

describe :array_select, shared: true do
it_should_behave_like :enumeratorize

before :each do
@object = [1,2,3]
end
it_should_behave_like :enumeratorized_with_origin_size

it "returns a new array of elements for which block is true" do
[1, 3, 4, 5, 6, 9].send(@method) { |i| i % ((i + 1) / 2) == 0}.should == [1, 4, 6]
end

it "does not return subclass instance on Array subclasses" do
ArraySpecs::MyArray[1, 2, 3].send(@method) { true }.should be_an_instance_of(Array)
end

it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty.send(@method) { true }.should == empty
empty.send(@method) { false }.should == []

array = ArraySpecs.recursive_array
array.send(@method) { true }.should == [1, 'two', 3.0, array, array, array, array, array]
array.send(@method) { false }.should == []
end
end
40 changes: 24 additions & 16 deletions spec/ruby/core/encoding/converter/last_error_spec.rb
Original file line number Diff line number Diff line change
@@ -55,31 +55,39 @@
it "returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one" do
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
exception = nil
lambda do
begin
ec.convert("\xf1abcd")
rescue Encoding::InvalidByteSequenceError => e
exception = e
raise e
end
end.should raise_error(Encoding::InvalidByteSequenceError)
-> {
ec.convert("\xf1abcd")
}.should raise_error(Encoding::InvalidByteSequenceError) { |e|
exception = e
}
ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError)
ec.last_error.message.should == exception.message
end

it "returns an Encoding::UndefinedConversionError when the last call to #convert produced one" do
ec = Encoding::Converter.new("utf-8", "iso-8859-1")
exception = nil
lambda do
begin
ec.convert("\u{9899}")
rescue Encoding::UndefinedConversionError => e
exception = e
raise e
end
end.should raise_error(Encoding::UndefinedConversionError)
-> {
ec.convert("\u{9899}")
}.should raise_error(Encoding::UndefinedConversionError) { |e|
exception = e
}
ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
ec.last_error.message.should == exception.message
ec.last_error.message.should include "from UTF-8 to ISO-8859-1"
end

it "returns the last error of #convert with a message showing the transcoding path" do
ec = Encoding::Converter.new("iso-8859-1", "Big5")
exception = nil
-> {
ec.convert("\xE9") # é in ISO-8859-1
}.should raise_error(Encoding::UndefinedConversionError) { |e|
exception = e
}
ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError)
ec.last_error.message.should == exception.message
ec.last_error.message.should include "from ISO-8859-1 to UTF-8 to Big5"
end
end
end
31 changes: 10 additions & 21 deletions spec/ruby/core/encoding/default_external_spec.rb
Original file line number Diff line number Diff line change
@@ -15,25 +15,8 @@
end

it "returns the default external encoding" do
Encoding.default_external = Encoding::UTF_8
Encoding.default_external.should == Encoding::UTF_8
end

describe "with command line options" do
it "is not changed by the -U option" do
result = ruby_exe("print Encoding.default_external", options: '-U')
result.should == Encoding.default_external.name
end

it "returns the encoding specified by '-E external'" do
result = ruby_exe("print Encoding.default_external", options: '-E euc-jp')
result.should == "EUC-JP"
end

it "returns the encoding specified by '-E external:'" do
result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:')
result.should == "Shift_JIS"
end
Encoding.default_external = Encoding::SHIFT_JIS
Encoding.default_external.should == Encoding::SHIFT_JIS
end
end

@@ -47,8 +30,14 @@
end

it "sets the default external encoding" do
Encoding.default_external = Encoding::UTF_8
Encoding.default_external.should == Encoding::UTF_8
Encoding.default_external = Encoding::SHIFT_JIS
Encoding.default_external.should == Encoding::SHIFT_JIS
Encoding.find('external').should == Encoding::SHIFT_JIS
end

it "also sets the filesystem encoding" do
Encoding.default_external = Encoding::SHIFT_JIS
Encoding.find('filesystem').should == Encoding::SHIFT_JIS
end

it "can accept a name of an encoding as a String" do
17 changes: 0 additions & 17 deletions spec/ruby/core/encoding/default_internal_spec.rb
Original file line number Diff line number Diff line change
@@ -28,23 +28,6 @@
Encoding.default_internal = Encoding::ASCII_8BIT
Encoding.default_internal.should == Encoding::ASCII_8BIT
end

describe "with command line options" do
it "returns Encoding::UTF_8 if ruby was invoked with -U" do
ruby_exe("print Encoding.default_internal", options: '-U').
should == 'UTF-8'
end

it "uses the encoding specified when ruby is invoked with an '-E :internal' argument" do
ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS').
should == 'Shift_JIS'
end

it "uses the encoding specified when ruby is invoked with an '-E external:internal' argument" do
ruby_exe("print Encoding.default_internal", options: '-E UTF-8:SHIFT_JIS').
should == 'Shift_JIS'
end
end
end

describe "Encoding.default_internal=" do
9 changes: 9 additions & 0 deletions spec/ruby/core/enumerable/filter_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('../fixtures/classes', __FILE__)
require File.expand_path('../shared/find_all', __FILE__)

ruby_version_is "2.6" do
describe "Enumerable#filter" do
it_behaves_like(:enumerable_find_all , :filter)
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/env/shared/to_hash.rb
Original file line number Diff line number Diff line change
@@ -17,6 +17,6 @@

it "duplicates the ENV when converting to a Hash" do
h = ENV.send(@method)
h.object_id.should_not == ENV.object_id
h.should_not equal ENV
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/exception/no_method_error_spec.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
NoMethodErrorSpecs::NoMethodErrorB.new.foo(1,a)
rescue Exception => e
e.args.should == [1,a]
e.args[1].object_id.should == a.object_id
e.args[1].should equal a
end
end
end
Loading