From 43b95bafd57d04c8fb401d3a9b52aca3f5b4b0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Mon, 27 Jul 2020 11:15:50 +0900 Subject: delete deprecated IO-like methods This commit deletes {IO,ARGF,StringIO,Zib::GZipReader}#{bytes,chars,lines,codepoints}, which have been deprecated since c47c095b9740e7c19d6fdca29ab661c1089221d4. Note that String also has those methods. They are neither depreacted nor deleted because they are not aliases of counterpart each_something. --- spec/ruby/core/argf/bytes_spec.rb | 6 ++- spec/ruby/core/argf/chars_spec.rb | 6 ++- spec/ruby/core/argf/codepoints_spec.rb | 6 ++- spec/ruby/core/argf/lines_spec.rb | 6 ++- spec/ruby/core/io/bytes_spec.rb | 64 ++++++++++++++++---------------- spec/ruby/core/io/chars_spec.rb | 12 +++--- spec/ruby/core/io/codepoints_spec.rb | 33 ++++++++-------- spec/ruby/core/io/each_codepoint_spec.rb | 2 +- spec/ruby/core/io/lines_spec.rb | 52 +++++++++++++------------- 9 files changed, 102 insertions(+), 85 deletions(-) (limited to 'spec/ruby/core') diff --git a/spec/ruby/core/argf/bytes_spec.rb b/spec/ruby/core/argf/bytes_spec.rb index 71d07fabcb..58a7082fd2 100644 --- a/spec/ruby/core/argf/bytes_spec.rb +++ b/spec/ruby/core/argf/bytes_spec.rb @@ -1,6 +1,8 @@ require_relative '../../spec_helper' require_relative 'shared/each_byte' -describe "ARGF.bytes" do - it_behaves_like :argf_each_byte, :bytes +ruby_version_is ''...'2.8' do + describe "ARGF.bytes" do + it_behaves_like :argf_each_byte, :bytes + end end diff --git a/spec/ruby/core/argf/chars_spec.rb b/spec/ruby/core/argf/chars_spec.rb index ee79ea763b..b5105effdf 100644 --- a/spec/ruby/core/argf/chars_spec.rb +++ b/spec/ruby/core/argf/chars_spec.rb @@ -1,6 +1,8 @@ require_relative '../../spec_helper' require_relative 'shared/each_char' -describe "ARGF.chars" do - it_behaves_like :argf_each_char, :chars +ruby_version_is ''...'2.8' do + describe "ARGF.chars" do + it_behaves_like :argf_each_char, :chars + end end diff --git a/spec/ruby/core/argf/codepoints_spec.rb b/spec/ruby/core/argf/codepoints_spec.rb index 7aa8a761fe..d7b9d08aaa 100644 --- a/spec/ruby/core/argf/codepoints_spec.rb +++ b/spec/ruby/core/argf/codepoints_spec.rb @@ -1,6 +1,8 @@ require_relative '../../spec_helper' require_relative 'shared/each_codepoint' -describe "ARGF.codepoints" do - it_behaves_like :argf_each_codepoint, :codepoints +ruby_version_is ''...'2.8' do + describe "ARGF.codepoints" do + it_behaves_like :argf_each_codepoint, :codepoints + end end diff --git a/spec/ruby/core/argf/lines_spec.rb b/spec/ruby/core/argf/lines_spec.rb index 6ca6ff1256..620db4312f 100644 --- a/spec/ruby/core/argf/lines_spec.rb +++ b/spec/ruby/core/argf/lines_spec.rb @@ -1,6 +1,8 @@ require_relative '../../spec_helper' require_relative 'shared/each_line' -describe "ARGF.lines" do - it_behaves_like :argf_each_line, :lines +ruby_version_is ''...'2.8' do + describe "ARGF.lines" do + it_behaves_like :argf_each_line, :lines + end end diff --git a/spec/ruby/core/io/bytes_spec.rb b/spec/ruby/core/io/bytes_spec.rb index feeb493566..f0e993e8f0 100644 --- a/spec/ruby/core/io/bytes_spec.rb +++ b/spec/ruby/core/io/bytes_spec.rb @@ -2,42 +2,44 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' -describe "IO#bytes" do - before :each do - @io = IOSpecs.io_fixture "lines.txt" - end - - after :each do - @io.close unless @io.closed? - end +ruby_version_is ''...'2.8' do + describe "IO#bytes" do + before :each do + @io = IOSpecs.io_fixture "lines.txt" + end - it "returns an enumerator of the next bytes from the stream" do - enum = @io.bytes - enum.should be_an_instance_of(Enumerator) - @io.readline.should == "Voici la ligne une.\n" - enum.first(5).should == [81, 117, 105, 32, 195] - end + after :each do + @io.close unless @io.closed? + end - it "yields each byte" do - count = 0 - ScratchPad.record [] - @io.each_byte do |byte| - ScratchPad << byte - break if 4 < count += 1 + it "returns an enumerator of the next bytes from the stream" do + enum = @io.bytes + enum.should be_an_instance_of(Enumerator) + @io.readline.should == "Voici la ligne une.\n" + enum.first(5).should == [81, 117, 105, 32, 195] end - ScratchPad.recorded.should == [86, 111, 105, 99, 105] - end + it "yields each byte" do + count = 0 + ScratchPad.record [] + @io.each_byte do |byte| + ScratchPad << byte + break if 4 < count += 1 + end - it "raises an IOError on closed stream" do - enum = IOSpecs.closed_io.bytes - -> { enum.first }.should raise_error(IOError) - end + ScratchPad.recorded.should == [86, 111, 105, 99, 105] + end - it "raises an IOError on an enumerator for a stream that has been closed" do - enum = @io.bytes - enum.first.should == 86 - @io.close - -> { enum.first }.should raise_error(IOError) + it "raises an IOError on closed stream" do + enum = IOSpecs.closed_io.bytes + -> { enum.first }.should raise_error(IOError) + end + + it "raises an IOError on an enumerator for a stream that has been closed" do + enum = @io.bytes + enum.first.should == 86 + @io.close + -> { enum.first }.should raise_error(IOError) + end end end diff --git a/spec/ruby/core/io/chars_spec.rb b/spec/ruby/core/io/chars_spec.rb index cd5dbbce4f..2efbdd7333 100644 --- a/spec/ruby/core/io/chars_spec.rb +++ b/spec/ruby/core/io/chars_spec.rb @@ -3,10 +3,12 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' require_relative 'shared/chars' -describe "IO#chars" do - it_behaves_like :io_chars, :chars -end +ruby_version_is ''...'2.8' do + describe "IO#chars" do + it_behaves_like :io_chars, :chars + end -describe "IO#chars" do - it_behaves_like :io_chars_empty, :chars + describe "IO#chars" do + it_behaves_like :io_chars_empty, :chars + end end diff --git a/spec/ruby/core/io/codepoints_spec.rb b/spec/ruby/core/io/codepoints_spec.rb index 915d99c027..1138989427 100644 --- a/spec/ruby/core/io/codepoints_spec.rb +++ b/spec/ruby/core/io/codepoints_spec.rb @@ -2,24 +2,27 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' require_relative 'shared/codepoints' -# See redmine #1667 -describe "IO#codepoints" do - it_behaves_like :io_codepoints, :codepoints -end +ruby_version_is ''...'2.8' do -describe "IO#codepoints" do - before :each do - @io = IOSpecs.io_fixture "lines.txt" + # See redmine #1667 + describe "IO#codepoints" do + it_behaves_like :io_codepoints, :codepoints end - after :each do - @io.close unless @io.closed? - end + describe "IO#codepoints" do + before :each do + @io = IOSpecs.io_fixture "lines.txt" + end + + after :each do + @io.close unless @io.closed? + end - it "calls the given block" do - r = [] - @io.codepoints { |c| r << c } - r[24].should == 232 - r.last.should == 10 + it "calls the given block" do + r = [] + @io.codepoints { |c| r << c } + r[24].should == 232 + r.last.should == 10 + end end end diff --git a/spec/ruby/core/io/each_codepoint_spec.rb b/spec/ruby/core/io/each_codepoint_spec.rb index cddc6b4662..07a4037c8a 100644 --- a/spec/ruby/core/io/each_codepoint_spec.rb +++ b/spec/ruby/core/io/each_codepoint_spec.rb @@ -4,7 +4,7 @@ require_relative 'shared/codepoints' # See redmine #1667 describe "IO#each_codepoint" do - it_behaves_like :io_codepoints, :codepoints + it_behaves_like :io_codepoints, :each_codepoint end describe "IO#each_codepoint" do diff --git a/spec/ruby/core/io/lines_spec.rb b/spec/ruby/core/io/lines_spec.rb index a8b8023a2a..dcf5825259 100644 --- a/spec/ruby/core/io/lines_spec.rb +++ b/spec/ruby/core/io/lines_spec.rb @@ -2,41 +2,43 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' -describe "IO#lines" do - before :each do - @io = IOSpecs.io_fixture "lines.txt" - end - - after :each do - @io.close if @io - end +ruby_version_is ''...'2.8' do + describe "IO#lines" do + before :each do + @io = IOSpecs.io_fixture "lines.txt" + end - it "returns an Enumerator" do - @io.lines.should be_an_instance_of(Enumerator) - end + after :each do + @io.close if @io + end - describe "when no block is given" do it "returns an Enumerator" do @io.lines.should be_an_instance_of(Enumerator) end - describe "returned Enumerator" do - describe "size" do - it "should return nil" do - @io.lines.size.should == nil + describe "when no block is given" do + it "returns an Enumerator" do + @io.lines.should be_an_instance_of(Enumerator) + end + + describe "returned Enumerator" do + describe "size" do + it "should return nil" do + @io.lines.size.should == nil + end end end end - end - it "returns a line when accessed" do - enum = @io.lines - enum.first.should == IOSpecs.lines[0] - end + it "returns a line when accessed" do + enum = @io.lines + enum.first.should == IOSpecs.lines[0] + end - it "yields each line to the passed block" do - ScratchPad.record [] - @io.lines { |s| ScratchPad << s } - ScratchPad.recorded.should == IOSpecs.lines + it "yields each line to the passed block" do + ScratchPad.record [] + @io.lines { |s| ScratchPad << s } + ScratchPad.recorded.should == IOSpecs.lines + end end end -- cgit v1.2.3