diff options
author | Benoit Daloze <[email protected]> | 2019-09-29 16:03:58 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2019-09-29 16:03:58 +0200 |
commit | 1c938a72aa9378f982dbc55327e86150c47b8707 (patch) | |
tree | 34a0bb0a45396c26eed111877a810c3aa793bff5 /spec/ruby/core/io | |
parent | 31bb66a19df26409c9d47afcf37919c9a065516a (diff) |
Update to ruby/spec@519df35
Diffstat (limited to 'spec/ruby/core/io')
-rw-r--r-- | spec/ruby/core/io/initialize_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/io/pipe_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/io/read_spec.rb | 16 | ||||
-rw-r--r-- | spec/ruby/core/io/reopen_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/binwrite.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/new.rb | 44 | ||||
-rw-r--r-- | spec/ruby/core/io/shared/readlines.rb | 8 |
7 files changed, 41 insertions, 37 deletions
diff --git a/spec/ruby/core/io/initialize_spec.rb b/spec/ruby/core/io/initialize_spec.rb index c8f3faf110..c0d84765a8 100644 --- a/spec/ruby/core/io/initialize_spec.rb +++ b/spec/ruby/core/io/initialize_spec.rb @@ -4,7 +4,7 @@ require_relative 'fixtures/classes' 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 diff --git a/spec/ruby/core/io/pipe_spec.rb b/spec/ruby/core/io/pipe_spec.rb index 5b2f18d836..a7dcb7fab8 100644 --- a/spec/ruby/core/io/pipe_spec.rb +++ b/spec/ruby/core/io/pipe_spec.rb @@ -179,7 +179,7 @@ describe "IO.pipe" do 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 diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb index 267d840cd3..1e9a8d2a4f 100644 --- a/spec/ruby/core/io/read_spec.rb +++ b/spec/ruby/core/io/read_spec.rb @@ -24,35 +24,35 @@ describe "IO.read" do 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 diff --git a/spec/ruby/core/io/reopen_spec.rb b/spec/ruby/core/io/reopen_spec.rb index 133ff03ea5..975f654b66 100644 --- a/spec/ruby/core/io/reopen_spec.rb +++ b/spec/ruby/core/io/reopen_spec.rb @@ -230,7 +230,7 @@ describe "IO#reopen with an IO" do 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 diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb index 17682a1a93..29310e1eaf 100644 --- a/spec/ruby/core/io/shared/binwrite.rb +++ b/spec/ruby/core/io/shared/binwrite.rb @@ -56,7 +56,7 @@ describe :io_binwrite, shared: true do 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 @@ -72,7 +72,7 @@ describe :io_binwrite, shared: true do 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 diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index 2101958170..cc76955784 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -89,59 +89,59 @@ describe :io_new, shared: true do 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 @@ -157,12 +157,12 @@ describe :io_new, shared: true do 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 @@ -173,7 +173,7 @@ describe :io_new, shared: true do # #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 @@ -198,7 +198,9 @@ describe :io_new, shared: true do 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 @@ -247,13 +249,13 @@ describe :io_new, shared: true do 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 @@ -307,13 +309,13 @@ describe :io_new_errors, shared: true do 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 @@ -372,7 +374,9 @@ describe :io_new_errors, shared: true do 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 diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb index 9bc02da0bd..de803f42e5 100644 --- a/spec/ruby/core/io/shared/readlines.rb +++ b/spec/ruby/core/io/shared/readlines.rb @@ -107,7 +107,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, 10, options, &@object) + IO.send(@method, @filename, 10, **options, &@object) end.should raise_error(IOError) end end @@ -135,7 +135,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, " ", options, &@object) + IO.send(@method, @filename, " ", **options, &@object) end.should raise_error(IOError) end end @@ -170,7 +170,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, " ", options, &@object) + IO.send(@method, @filename, " ", **options, &@object) end.should raise_error(IOError) end end @@ -202,7 +202,7 @@ describe :io_readlines_options_19, shared: true do options = mock("io readlines options Hash") options.should_receive(:to_hash).and_return({ mode: "w" }) -> do - IO.send(@method, @filename, " ", 10, options, &@object) + IO.send(@method, @filename, " ", 10, **options, &@object) end.should raise_error(IOError) end end |