Skip to content

Commit

Permalink
Update to ruby/spec@519df35
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Sep 29, 2019
1 parent 31bb66a commit 1c938a7
Show file tree
Hide file tree
Showing 83 changed files with 1,416 additions and 308 deletions.
28 changes: 0 additions & 28 deletions spec/ruby/.travis.yml

This file was deleted.

34 changes: 0 additions & 34 deletions spec/ruby/appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion spec/ruby/core/dir/shared/open.rb
Expand Up @@ -52,7 +52,7 @@
options = mock("dir_open")
options.should_receive(:to_hash).and_return({ encoding: Encoding::UTF_8 })

dir = Dir.send(@method, DirSpecs.mock_dir, options) {|d| d }
dir = Dir.send(@method, DirSpecs.mock_dir, **options) {|d| d }
dir.should be_kind_of(Dir)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/encoding/converter/convpath_spec.rb
Expand Up @@ -15,10 +15,10 @@
end

it "indicates if crlf_newline conversion would occur" do
ec = Encoding::Converter.new("ISo-8859-1", "EUC-JP", {crlf_newline: true})
ec = Encoding::Converter.new("ISo-8859-1", "EUC-JP", crlf_newline: true)
ec.convpath.last.should == "crlf_newline"

ec = Encoding::Converter.new("ASCII", "UTF-8", {crlf_newline: false})
ec = Encoding::Converter.new("ASCII", "UTF-8", crlf_newline: false)
ec.convpath.last.should_not == "crlf_newline"
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/encoding/converter/new_spec.rb
Expand Up @@ -50,7 +50,7 @@
it "calls #to_hash to convert the options argument to a Hash if not a Fixnum" do
opts = mock("encoding converter options")
opts.should_receive(:to_hash).and_return({ replace: "fubar" })
conv = Encoding::Converter.new("us-ascii", "utf-8", opts)
conv = Encoding::Converter.new("us-ascii", "utf-8", **opts)
conv.replacement.should == "fubar"
end

Expand Down
Expand Up @@ -85,7 +85,7 @@
end

it "accepts an options hash" do
@ec.primitive_convert("","",nil,nil, {after_output: true}).should == :finished
@ec.primitive_convert("","",nil,nil, after_output: true).should == :finished
end

it "sets the destination buffer's encoding to the destination encoding if the conversion succeeded" do
Expand Down
6 changes: 2 additions & 4 deletions spec/ruby/core/encoding/converter/search_convpath_spec.rb
Expand Up @@ -15,12 +15,10 @@
end

it "indicates if crlf_newline conversion would occur" do
cp = Encoding::Converter.search_convpath(
"ISO-8859-1", "EUC-JP", {crlf_newline: true})
cp = Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", crlf_newline: true)
cp.last.should == "crlf_newline"

cp = Encoding::Converter.search_convpath(
"ASCII", "UTF-8", {crlf_newline: false})
cp = Encoding::Converter.search_convpath("ASCII", "UTF-8", crlf_newline: false)
cp.last.should_not == "crlf_newline"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/file/open_spec.rb
Expand Up @@ -566,7 +566,7 @@
options = mock("file open options")
options.should_receive(:to_hash).and_return({ mode: "r" })

@fh = File.open(@file, options)
@fh = File.open(@file, **options)
end

it "accepts extra flags as a keyword argument and combine with a string mode" do
Expand Down
4 changes: 4 additions & 0 deletions spec/ruby/core/hash/fetch_values_spec.rb
Expand Up @@ -12,6 +12,10 @@
@hash.fetch_values(:a).should == [1]
@hash.fetch_values(:a, :c).should == [1, 3]
end

it "returns the values for keys ordered in the order of the requested keys" do
@hash.fetch_values(:c, :a).should == [3, 1]
end
end

describe "with unmatched keys" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/io/initialize_spec.rb
Expand Up @@ -4,7 +4,7 @@
describe "IO#initialize" do
before :each do
@name = tmp("io_initialize.txt")
@io = new_io @name
@io = IO.new(new_fd(@name))
@fd = @io.fileno
end

Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/io/pipe_spec.rb
Expand Up @@ -179,7 +179,7 @@
it "calls #to_hash to convert an options argument" do
options = mock("io pipe encoding options")
options.should_receive(:to_hash).and_return({ invalid: :replace })
IO.pipe("UTF-8", "ISO-8859-1", options) { |r, w| }
IO.pipe("UTF-8", "ISO-8859-1", **options) { |r, w| }
end

it "calls #to_str to convert the first argument to a String" do
Expand Down
16 changes: 8 additions & 8 deletions spec/ruby/core/io/read_spec.rb
Expand Up @@ -24,35 +24,35 @@
end

it "accepts an empty options Hash" do
IO.read(@fname, {}).should == @contents
IO.read(@fname, **{}).should == @contents
end

it "accepts a length, and empty options Hash" do
IO.read(@fname, 3, {}).should == @contents[0, 3]
IO.read(@fname, 3, **{}).should == @contents[0, 3]
end

it "accepts a length, offset, and empty options Hash" do
IO.read(@fname, 3, 0, {}).should == @contents[0, 3]
IO.read(@fname, 3, 0, **{}).should == @contents[0, 3]
end

it "raises an IOError if the options Hash specifies write mode" do
-> { IO.read(@fname, 3, 0, {mode: "w"}) }.should raise_error(IOError)
-> { IO.read(@fname, 3, 0, mode: "w") }.should raise_error(IOError)
end

it "raises an IOError if the options Hash specifies append only mode" do
-> { IO.read(@fname, {mode: "a"}) }.should raise_error(IOError)
-> { IO.read(@fname, mode: "a") }.should raise_error(IOError)
end

it "reads the file if the options Hash includes read mode" do
IO.read(@fname, {mode: "r"}).should == @contents
IO.read(@fname, mode: "r").should == @contents
end

it "reads the file if the options Hash includes read/write mode" do
IO.read(@fname, {mode: "r+"}).should == @contents
IO.read(@fname, mode: "r+").should == @contents
end

it "reads the file if the options Hash includes read/write append mode" do
IO.read(@fname, {mode: "a+"}).should == @contents
IO.read(@fname, mode: "a+").should == @contents
end

it "treats second nil argument as no length limit" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/io/reopen_spec.rb
Expand Up @@ -230,7 +230,7 @@
end

@io = new_io @name
@other_io = new_io @other_name, "r"
@other_io = IO.new(new_fd(@other_name, "r"), "r")
end

after :each do
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/io/shared/binwrite.rb
Expand Up @@ -56,7 +56,7 @@
end

it "doesn't truncate and writes at the given offset after passing empty opts" do
IO.send(@method, @filename, "hello world!", 1, {})
IO.send(@method, @filename, "hello world!", 1, **{})
File.read(@filename).should == "0hello world!34567890123456789"
end

Expand All @@ -72,7 +72,7 @@
end

it "truncates if empty :opts provided and offset skipped" do
IO.send(@method, @filename, "hello, world!", {})
IO.send(@method, @filename, "hello, world!", **{})
File.read(@filename).should == "hello, world!"
end
end
44 changes: 24 additions & 20 deletions spec/ruby/core/io/shared/new.rb
Expand Up @@ -89,59 +89,59 @@
end

it "uses the external encoding specified via the :external_encoding option" do
@io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8'})
@io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8')
@io.external_encoding.to_s.should == 'UTF-8'
end

it "uses the internal encoding specified via the :internal_encoding option" do
@io = IO.send(@method, @fd, 'w', {internal_encoding: 'ibm866'})
@io = IO.send(@method, @fd, 'w', internal_encoding: 'ibm866')
@io.internal_encoding.to_s.should == 'IBM866'
end

it "uses the colon-separated encodings specified via the :encoding option" do
@io = IO.send(@method, @fd, 'w', {encoding: 'utf-8:ISO-8859-1'})
@io = IO.send(@method, @fd, 'w', encoding: 'utf-8:ISO-8859-1')
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == 'ISO-8859-1'
end

it "uses the :encoding option as the external encoding when only one is given" do
@io = IO.send(@method, @fd, 'w', {encoding: 'ISO-8859-1'})
@io = IO.send(@method, @fd, 'w', encoding: 'ISO-8859-1')
@io.external_encoding.to_s.should == 'ISO-8859-1'
end

it "uses the :encoding options as the external encoding when it's an Encoding object" do
@io = IO.send(@method, @fd, 'w', {encoding: Encoding::ISO_8859_1})
@io = IO.send(@method, @fd, 'w', encoding: Encoding::ISO_8859_1)
@io.external_encoding.should == Encoding::ISO_8859_1
end

it "ignores the :encoding option when the :external_encoding option is present" do
-> {
@io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', encoding: 'iso-8859-1:iso-8859-1'})
@io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', encoding: 'iso-8859-1:iso-8859-1')
}.should complain(/Ignoring encoding parameter/)
@io.external_encoding.to_s.should == 'UTF-8'
end

it "ignores the :encoding option when the :internal_encoding option is present" do
-> {
@io = IO.send(@method, @fd, 'w', {internal_encoding: 'ibm866', encoding: 'iso-8859-1:iso-8859-1'})
@io = IO.send(@method, @fd, 'w', internal_encoding: 'ibm866', encoding: 'iso-8859-1:iso-8859-1')
}.should complain(/Ignoring encoding parameter/)
@io.internal_encoding.to_s.should == 'IBM866'
end

it "uses the encoding specified via the :mode option hash" do
@io = IO.send(@method, @fd, {mode: 'w:utf-8:ISO-8859-1'})
@io = IO.send(@method, @fd, mode: 'w:utf-8:ISO-8859-1')
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == 'ISO-8859-1'
end

it "ignores the :internal_encoding option when the same as the external encoding" do
@io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', internal_encoding: 'utf-8'})
@io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', internal_encoding: 'utf-8')
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == ''
end

it "sets internal encoding to nil when passed '-'" do
@io = IO.send(@method, @fd, 'w', {external_encoding: 'utf-8', internal_encoding: '-'})
@io = IO.send(@method, @fd, 'w', external_encoding: 'utf-8', internal_encoding: '-')
@io.external_encoding.to_s.should == 'UTF-8'
@io.internal_encoding.to_s.should == ''
end
Expand All @@ -157,12 +157,12 @@
end

it "sets binmode from :binmode option" do
@io = IO.send(@method, @fd, 'w', {binmode: true})
@io = IO.send(@method, @fd, 'w', binmode: true)
@io.binmode?.should == true
end

it "does not set binmode from false :binmode" do
@io = IO.send(@method, @fd, 'w', {binmode: false})
@io = IO.send(@method, @fd, 'w', binmode: false)
@io.binmode?.should == false
end

Expand All @@ -173,7 +173,7 @@

# #5917
it "sets external encoding to binary with :binmode option" do
@io = IO.send(@method, @fd, 'w', {binmode: true})
@io = IO.send(@method, @fd, 'w', binmode: true)
@io.external_encoding.should == Encoding::BINARY
end

Expand All @@ -198,7 +198,9 @@
end

it "accepts nil options" do
@io = IO.send(@method, @fd, 'w', nil)
@io = suppress_keyword_warning do
IO.send(@method, @fd, 'w', nil)
end
@io.write("foo").should == 3
end

Expand Down Expand Up @@ -247,13 +249,13 @@
it "coerces options as third argument with #to_hash" do
options = mock("options")
options.should_receive(:to_hash).and_return({})
@io = IO.send(@method, @fd, 'w', options)
@io = IO.send(@method, @fd, 'w', **options)
end

it "coerces options as second argument with #to_hash" do
options = mock("options")
options.should_receive(:to_hash).and_return({})
@io = IO.send(@method, @fd, options)
@io = IO.send(@method, @fd, **options)
end

it "accepts an :autoclose option" do
Expand Down Expand Up @@ -307,13 +309,13 @@

it "raises an error if passed encodings two ways" do
-> {
@io = IO.send(@method, @fd, 'w:ISO-8859-1', {encoding: 'ISO-8859-1'})
@io = IO.send(@method, @fd, 'w:ISO-8859-1', encoding: 'ISO-8859-1')
}.should raise_error(ArgumentError)
-> {
@io = IO.send(@method, @fd, 'w:ISO-8859-1', {external_encoding: 'ISO-8859-1'})
@io = IO.send(@method, @fd, 'w:ISO-8859-1', external_encoding: 'ISO-8859-1')
}.should raise_error(ArgumentError)
-> {
@io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', {internal_encoding: 'ISO-8859-1'})
@io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1')
}.should raise_error(ArgumentError)
end

Expand Down Expand Up @@ -372,7 +374,9 @@

it "raises TypeError if passed a hash for mode and nil for options" do
-> {
@io = IO.send(@method, @fd, {mode: 'w'}, nil)
suppress_keyword_warning do
@io = IO.send(@method, @fd, {mode: 'w'}, nil)
end
}.should raise_error(TypeError)
end
end

0 comments on commit 1c938a7

Please sign in to comment.