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

Commits on Jan 27, 2017

  1. Squashed 'spec/mspec/' changes from d44a977..4bcdee5

    4bcdee5 Recognise :truffleruby, tag failing specs
    f4131988 Deprecate the have_data matcher
    f77ea8d Revert "Clean SPEC_TEMP_DIR when starting mspec"
    23fa974 Clean SPEC_TEMP_DIR when starting mspec
    
    git-subtree-dir: spec/mspec
    git-subtree-split: 4bcdee51406abc739ebe2a6be81ec5a93447125e
    eregon committed Jan 27, 2017
    Copy the full SHA
    90286ce View commit details
  2. Copy the full SHA
    18eedc0 View commit details
  3. Squashed 'spec/ruby/' changes from f4a4f0e..fb3e3ac

    fb3e3ac Remove redundant specs
    89b75f6 Write to an external file instead of using output_to_fd
    a1837cb If you change the max of a sized queue, the old items beyond the max remain
    f3b9b2d change TruffleRuby's RUBY_ENGINE to ruby until we are recognised by rubygems
    5792e29 Simplify Array#sample spec and avoid #itself
    1af4646 add array sample randomness spec
    086ccc5 Fix a spec typo
    ac4cabf Add link to TruffleRuby
    8dcc2ca Remove old JRuby+Truffle link
    c8eda60 Add spec for Enumerable#chunk_while with single element.
    f8e0ea5 Add spec for invalid rescue clauses
    19ec73a Spec for rescue comparing against classes using ===
    61b4c61 add spec for String#scan's output when passed block has multiple arguments
    6047836 Fix bad spec which inadvertently passed due to have_data.
    2268696 Replace have_data matchers with File.read().should ==
    ca87e50 Merge pull request #383 from manu-crealytics/gzipreader_enumerator_specs
    1c4d467 Extend GzipReader specs to cover returned Enumerators.
    859eeb0 Kerenel#warn no longer splats an array in 2.5 (#382)
    cee9571 Extract WIN32OLE.new to a fixture to ease retrying
    0079c36 Merge pull request #379 from kachick/2.4-match-p
    9b95f54 Merge pull request #377 from kachick/hash-transform_values
    96735c5 Merge pull request #376 from kachick/hash-compact
    5be340b Write specs around {String|Symbol}#match?
    95b9bbb Write specs around Regexp#match?
    ef69806 Merge pull request #375 from kachick/concat-prepend-with-multi-arg
    9496ea5 Remove suspicious spec
    28a88ed Remove empty WIN32OLE specs
    ab2925b Retry on WIN32OLE.new failure
    db38e03 Avoid double error
    2d281a2 Temporarily disable new spec for String#each_line in 2.5 as Travis trunk lags
    2d08e6d Enable 2.4.0 in CI
    80f92c2 Write Hash#transform_values! specs around frozen
    5611438 Write Hash#transform_values! specs
    4d31731 Write Hash#transform_values specs
    906bd11 suppress error for a while
    dd2360f Write Hash#compact{!} specs
    6f66a66 Add Array#concat with multiple arguments
    d650d57 Add String#concat with multiple arguments
    9020e16 Add String#prepend with multiple arguments
    c4a0aa2 Sort by versions
    85b2434 Merge pull request #371 from vais/windows
    eaf3da5 There is no /dev/tty on Windows, but the rest of the tty spec works
    9b81e7d Don't leave zombie IE processes hanging around after specs finish running
    f9e6b34 There is no /dev/tty on Windows
    dc9c3e1 Silence the nuisance "'does_not_exist' is not recognized..." message
    
    git-subtree-dir: spec/ruby
    git-subtree-split: fb3e3ac203386b2b82a7787490ed4f861ab4169e
    eregon committed Jan 27, 2017
    Copy the full SHA
    d83cbf7 View commit details
  4. Copy the full SHA
    60e0d88 View commit details
Showing with 636 additions and 277 deletions.
  1. +3 −1 spec/mspec/lib/mspec/guards/guard.rb
  2. +1 −1 spec/mspec/lib/mspec/helpers/numeric.rb
  3. +2 −0 spec/mspec/lib/mspec/matchers/have_data.rb
  4. +1 −0 spec/ruby/.travis.yml
  5. +1 −0 spec/ruby/README.md
  6. +20 −0 spec/ruby/core/array/concat_spec.rb
  7. +13 −0 spec/ruby/core/array/sample_spec.rb
  8. +4 −4 spec/ruby/core/file/open_spec.rb
  9. +1 −1 spec/ruby/core/file/truncate_spec.rb
  10. +61 −0 spec/ruby/core/hash/compact_spec.rb
  11. +71 −0 spec/ruby/core/hash/transform_values_spec.rb
  12. +13 −13 spec/ruby/core/io/copy_stream_spec.rb
  13. +2 −2 spec/ruby/core/io/popen_spec.rb
  14. +2 −2 spec/ruby/core/io/printf_spec.rb
  15. +6 −6 spec/ruby/core/io/reopen_spec.rb
  16. +11 −9 spec/ruby/core/io/shared/tty.rb
  17. +2 −2 spec/ruby/core/io/write_spec.rb
  18. +1 −1 spec/ruby/core/kernel/system_spec.rb
  19. +16 −5 spec/ruby/core/kernel/warn_spec.rb
  20. +29 −0 spec/ruby/core/regexp/match_spec.rb
  21. +20 −0 spec/ruby/core/string/concat_spec.rb
  22. +25 −0 spec/ruby/core/string/match_spec.rb
  23. +21 −1 spec/ruby/core/string/prepend_spec.rb
  24. +8 −0 spec/ruby/core/string/scan_spec.rb
  25. +18 −12 spec/ruby/core/string/shared/each_line.rb
  26. +25 −0 spec/ruby/core/symbol/match_spec.rb
  27. +1 −1 spec/ruby/language/yield_spec.rb
  28. +11 −0 spec/ruby/library/thread/sizedqueue/max_spec.rb
  29. +14 −0 spec/ruby/library/win32ole/fixtures/classes.rb
  30. +7 −3 spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
  31. +3 −1 spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
  32. +0 −1 spec/ruby/library/win32ole/win32ole/_setproperty_spec.rb
  33. +2 −0 spec/ruby/library/win32ole/win32ole/codepage_spec.rb
  34. +2 −0 spec/ruby/library/win32ole/win32ole/connect_spec.rb
  35. +4 −2 spec/ruby/library/win32ole/win32ole/const_load_spec.rb
  36. +2 −0 spec/ruby/library/win32ole/win32ole/constants_spec.rb
  37. +2 −0 spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
  38. +0 −1 spec/ruby/library/win32ole/win32ole/each_spec.rb
  39. +7 −1 spec/ruby/library/win32ole/win32ole/invoke_spec.rb
  40. +2 −0 spec/ruby/library/win32ole/win32ole/locale_spec.rb
  41. +7 −5 spec/ruby/library/win32ole/win32ole/new_spec.rb
  42. +7 −3 spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
  43. +3 −1 spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
  44. +1 −0 spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
  45. +1 −0 spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
  46. +7 −3 spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
  47. +7 −3 spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
  48. +7 −3 spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
  49. +0 −7 spec/ruby/library/win32ole/win32ole/ole_show_help_spec.rb
  50. +1 −0 spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
  51. +7 −3 spec/ruby/library/win32ole/win32ole/shared/ole_method.rb
  52. +7 −3 spec/ruby/library/win32ole/win32ole/shared/setproperty.rb
  53. +0 −28 spec/ruby/library/win32ole/win32ole_event/handler_spec.rb
  54. +0 −11 spec/ruby/library/win32ole/win32ole_event/message_loop_spec.rb
  55. +7 −8 spec/ruby/library/win32ole/win32ole_event/new_spec.rb
  56. +0 −16 spec/ruby/library/win32ole/win32ole_event/off_event_spec.rb
  57. +10 −10 spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
  58. +0 −9 spec/ruby/library/win32ole/win32ole_event/on_event_with_outargs_spec.rb
  59. +0 −16 spec/ruby/library/win32ole/win32ole_event/unadvise_spec.rb
  60. +16 −0 spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
  61. +5 −1 spec/ruby/library/zlib/gzipreader/each_line_spec.rb
  62. +5 −1 spec/ruby/library/zlib/gzipreader/each_spec.rb
  63. +51 −0 spec/ruby/library/zlib/gzipreader/shared/each.rb
  64. +2 −2 spec/ruby/optional/capi/file_spec.rb
  65. +11 −11 spec/ruby/optional/capi/io_spec.rb
  66. +2 −2 spec/ruby/optional/capi/spec_helper.rb
  67. +1 −1 spec/ruby/shared/process/exec.rb
  68. +1 −1 spec/ruby/shared/process/fixtures/env.rb
  69. +36 −59 spec/ruby/shared/process/spawn.rb
4 changes: 3 additions & 1 deletion spec/mspec/lib/mspec/guards/guard.rb
Original file line number Diff line number Diff line change
@@ -119,9 +119,11 @@ def implementation?(*args)
when :rubinius
RUBY_NAME =~ /^rbx/
when :ruby
RUBY_NAME =~ /^ruby/
RUBY_NAME =~ /^ruby/ && !defined?(::Truffle)
when :jruby
RUBY_NAME =~ /^jruby/
when :truffleruby
RUBY_NAME =~ /^ruby/ && defined?(::Truffle)
when :ironruby
RUBY_NAME =~ /^ironruby/
when :macruby
2 changes: 1 addition & 1 deletion spec/mspec/lib/mspec/helpers/numeric.rb
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ def fixnum_max
def fixnum_min
Fixnum::MIN
end
elsif guard.implementation? :jruby
elsif guard.implementation?(:jruby) || guard.implementation?(:truffleruby)
# Values from jruby/test/testFixnumBignumAutoconversion.rb
def fixnum_max
9223372036854775807
2 changes: 2 additions & 0 deletions spec/mspec/lib/mspec/matchers/have_data.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'mspec/guards/feature'
require 'mspec/helpers/io'
require 'mspec/utils/deprecate'

class HaveDataMatcher
def initialize(data, mode="rb:binary")
@@ -46,6 +47,7 @@ class Object
# file can contain more bytes than +data+. The extra bytes do not
# affect the result.
def have_data(data, mode="rb:binary")
MSpec.deprecate "have_data", "File.read or File.binread(file).should == data"
HaveDataMatcher.new(data, mode)
end
end
1 change: 1 addition & 0 deletions spec/ruby/.travis.yml
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ rvm:
- 2.1.10
- 2.2.6
- 2.3.3
- 2.4.0
- ruby-head
install:
- git clone https://github.com/ruby/mspec.git ../mspec
1 change: 1 addition & 0 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ 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

### Running the specs
20 changes: 20 additions & 0 deletions spec/ruby/core/array/concat_spec.rb
Original file line number Diff line number Diff line change
@@ -109,4 +109,24 @@
3.times { ary.shift }
ary.concat([5, 6]).should == [4, 5, 6]
end

ruby_version_is "2.4" do
it "takes multiple arguments" do
ary = [1, 2]
ary.concat [3, 4]
ary.should == [1, 2, 3, 4]
end

it "concatenates the initial value when given arguments contain 2 self" do
ary = [1, 2]
ary.concat ary, ary
ary.should == [1, 2, 1, 2, 1, 2]
end

it "returns self when given no arguments" do
ary = [1, 2]
ary.concat.should equal(ary)
ary.should == [1, 2]
end
end
end
13 changes: 13 additions & 0 deletions spec/ruby/core/array/sample_spec.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,19 @@
require File.expand_path('../fixtures/classes', __FILE__)

describe "Array#sample" do
it "samples evenly" do
ary = [0, 1, 2, 3]
3.times do |i|
counts = [0, 0, 0, 0]
4000.times do
counts[ary.sample(3)[i]] += 1
end
counts.each do |count|
(800..1200).should include(count)
end
end
end

it "returns nil for an empty Array" do
[].sample.should be_nil
end
8 changes: 4 additions & 4 deletions spec/ruby/core/file/open_spec.rb
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@
# even though the file permissions are r-r-r.

File.open(@file, "w", 0444) { |f| f.write("test") }
@file.should have_data("test")
File.read(@file).should == "test"
end

platform_is_not :windows do
@@ -142,7 +142,7 @@
File.open(@file, "w", 0444) { |f| f.write("test") }

File.stat(@file).mode.to_s(8).should == orig_perms
@file.should have_data("test")
File.read(@file).should == "test"
end
end

@@ -655,7 +655,7 @@
@file.fileno.should equal(@fd)
@file.write @content
@file.flush
@name.should have_data(@content)
File.read(@name).should == @content
end

it "opens a file when passed a block" do
@@ -665,7 +665,7 @@
f.write @content
f
end
@name.should have_data(@content)
File.read(@name).should == @content
end
end

2 changes: 1 addition & 1 deletion spec/ruby/core/file/truncate_spec.rb
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@
@file.truncate(3)
@file.write "abc"
@file.close
@name.should have_data("123\x00\x00\x00\x00\x00\x00\x00abc")
File.read(@name).should == "123\x00\x00\x00\x00\x00\x00\x00abc"
end

it "does not move the file read pointer to the specified byte offset" do
61 changes: 61 additions & 0 deletions spec/ruby/core/hash/compact_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

ruby_version_is "2.4" do
describe "Hash#compact" do
before :each do
@hash = { truthy: true, false: false, nil: nil, nil => true }
@initial_pairs = @hash.dup
@compact = { truthy: true, false: false, nil => true }
end

it "returns new object that rejects pair has nil value" do
ret = @hash.compact
ret.should_not equal(@hash)
ret.should == @compact
end

it "keeps own pairs" do
@hash.compact
@hash.should == @initial_pairs
end
end

describe "Hash#compact!" do
before :each do
@hash = { truthy: true, false: false, nil: nil, nil => true }
@initial_pairs = @hash.dup
@compact = { truthy: true, false: false, nil => true }
end

it "returns self" do
@hash.compact!.should equal(@hash)
end

it "rejects own pair has nil value" do
@hash.compact!
@hash.should == @compact
end

context "when each pair does not have nil value" do
before :each do
@hash.compact!
end

it "returns nil" do
@hash.compact!.should be_nil
end
end

describe "on frozen instance" do
before :each do
@hash.freeze
end

it "keeps pairs and raises a RuntimeError" do
->{ @hash.compact! }.should raise_error(RuntimeError)
@hash.should == @initial_pairs
end
end
end
end
71 changes: 71 additions & 0 deletions spec/ruby/core/hash/transform_values_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "2.4" do
describe "Hash#transform_values" do
before :each do
@hash = { a: 1, b: 2, c: 3 }
end

it "returns new hash" do
ret = @hash.transform_values(&:succ)
ret.should_not equal(@hash)
ret.should be_an_instance_of(Hash)
end

it "sets the result as transformed values with the given block" do
@hash.transform_values(&:succ).should == { a: 2, b: 3, c: 4 }
end

context "when no block is given" do
it "returns a sized Enumerator" do
enumerator = @hash.transform_values
enumerator.should be_an_instance_of(enumerator_class)
enumerator.size.should == @hash.size
enumerator.each(&:succ).should == { a: 2, b: 3, c: 4 }
end
end
end

describe "Hash#transform_values!" do
before :each do
@hash = { a: 1, b: 2, c: 3 }
@initial_pairs = @hash.dup
end

it "returns self" do
@hash.transform_values!(&:succ).should equal(@hash)
end

it "updates self as transformed values with the given block" do
@hash.transform_values!(&:succ)
@hash.should == { a: 2, b: 3, c: 4 }
end

context "when no block is given" do
it "returns a sized Enumerator" do
enumerator = @hash.transform_values!
enumerator.should be_an_instance_of(enumerator_class)
enumerator.size.should == @hash.size
enumerator.each(&:succ)
@hash.should == { a: 2, b: 3, c: 4 }
end
end

describe "on frozen instance" do
before :each do
@hash.freeze
end

it "keeps pairs and raises a RuntimeError" do
->{ @hash.transform_values!(&:succ) }.should raise_error(RuntimeError)
@hash.should == @initial_pairs
end

context "when no block is given" do
it "does not raise an exception" do
@hash.transform_values!.should be_an_instance_of(enumerator_class)
end
end
end
end
end
26 changes: 13 additions & 13 deletions spec/ruby/core/io/copy_stream_spec.rb
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
describe :io_copy_stream_to_file, shared: true do
it "copies the entire IO contents to the file" do
IO.copy_stream(@object.from, @to_name)
@to_name.should have_data(@content)
File.read(@to_name).should == @content
IO.copy_stream(@from_bigfile, @to_name)
@to_name.should have_data(@content_bigfile)
File.read(@to_name).should == @content_bigfile
end

it "returns the number of bytes copied" do
@@ -16,15 +16,15 @@

it "copies only length bytes when specified" do
IO.copy_stream(@object.from, @to_name, 8).should == 8
@to_name.should have_data("Line one")
File.read(@to_name).should == "Line one"
end

it "calls #to_path to convert on object to a file name" do
obj = mock("io_copy_stream_to")
obj.should_receive(:to_path).and_return(@to_name)

IO.copy_stream(@object.from, obj)
@to_name.should have_data(@content)
File.read(@to_name).should == @content
end

it "raises a TypeError if #to_path does not return a String" do
@@ -39,17 +39,17 @@
platform_is_not :windows do
it "copies only length bytes from the offset" do
IO.copy_stream(@object.from, @to_name, 8, 4).should == 8
@to_name.should have_data(" one\n\nLi")
File.read(@to_name).should == " one\n\nLi"
end
end
end

describe :io_copy_stream_to_io, shared: true do
it "copies the entire IO contents to the IO" do
IO.copy_stream(@object.from, @to_io)
@to_name.should have_data(@content)
File.read(@to_name).should == @content
IO.copy_stream(@from_bigfile, @to_io)
@to_name.should have_data(@content + @content_bigfile)
File.read(@to_name).should == (@content + @content_bigfile)
end

it "returns the number of bytes copied" do
@@ -60,7 +60,7 @@
it "starts writing at the destination IO's current position" do
@to_io.write("prelude ")
IO.copy_stream(@object.from, @to_io)
@to_name.should have_data("prelude " + @content)
File.read(@to_name).should == ("prelude " + @content)
end

it "leaves the destination IO position at the last write" do
@@ -81,15 +81,15 @@

it "copies only length bytes when specified" do
IO.copy_stream(@object.from, @to_io, 8).should == 8
@to_name.should have_data("Line one")
File.read(@to_name).should == "Line one"
end
end

describe :io_copy_stream_to_io_with_offset, shared: true do
platform_is_not :windows do
it "copies only length bytes from the offset" do
IO.copy_stream(@object.from, @to_io, 8, 4).should == 8
@to_name.should have_data(" one\n\nLi")
File.read(@to_name).should == " one\n\nLi"
end
end
end
@@ -176,7 +176,7 @@
obj.should_receive(:to_path).and_return(@from_name)

IO.copy_stream(obj, @to_name)
@to_name.should have_data(@content)
File.read(@to_name).should == @content
end

it "raises a TypeError if #to_path does not return a String" do
@@ -256,14 +256,14 @@
from = IOSpecs::CopyStreamReadPartial.new @io

IO.copy_stream(from, @to_name)
@to_name.should have_data(@content)
File.read(@to_name).should == @content
end

it "calls #read on the source Object" do
from = IOSpecs::CopyStreamRead.new @io

IO.copy_stream(from, @to_name)
@to_name.should have_data(@content)
File.read(@to_name).should == @content
end

it "calls #write on the destination Object" do
4 changes: 2 additions & 2 deletions spec/ruby/core/io/popen_spec.rb
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
@io.write("bar")
@io.close

@fname.should have_data("bar")
File.read(@fname).should == "bar"
end

it "raises IOError when reading a write-only pipe" do
@@ -72,7 +72,7 @@

$?.exitstatus.should == 0

@fname.should have_data("bar")
File.read(@fname).should == "bar"
end

it "does not throw an exception if child exited and has been waited for" do
Loading