summaryrefslogtreecommitdiff
path: root/spec/ruby/core/io
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-06-27 21:02:36 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-06-27 21:02:36 +0200
commitd80e44deec77678fe2d72f94c17b2409b3e794d5 (patch)
tree612bf2313550e0982dda452f48492cc069e1c21a /spec/ruby/core/io
parentc940397116c5aef76b1c0d05561c11d43ef596a7 (diff)
Update to ruby/spec@8d74d49
Diffstat (limited to 'spec/ruby/core/io')
-rw-r--r--spec/ruby/core/io/binread_spec.rb8
-rw-r--r--spec/ruby/core/io/binwrite_spec.rb2
-rw-r--r--spec/ruby/core/io/external_encoding_spec.rb8
-rw-r--r--spec/ruby/core/io/gets_spec.rb14
-rw-r--r--spec/ruby/core/io/internal_encoding_spec.rb8
-rw-r--r--spec/ruby/core/io/read_spec.rb26
-rw-r--r--spec/ruby/core/io/readbyte_spec.rb2
-rw-r--r--spec/ruby/core/io/readlines_spec.rb6
-rw-r--r--spec/ruby/core/io/readpartial_spec.rb2
-rw-r--r--spec/ruby/core/io/set_encoding_spec.rb2
-rw-r--r--spec/ruby/core/io/shared/new.rb4
-rw-r--r--spec/ruby/core/io/write_spec.rb4
12 files changed, 41 insertions, 45 deletions
diff --git a/spec/ruby/core/io/binread_spec.rb b/spec/ruby/core/io/binread_spec.rb
index 5e936ac6ba..961044da58 100644
--- a/spec/ruby/core/io/binread_spec.rb
+++ b/spec/ruby/core/io/binread_spec.rb
@@ -28,13 +28,13 @@ describe "IO.binread" do
IO.binread(@fname, 5, 3).should == @contents.slice(3, 5)
end
- it "returns a String in ASCII-8BIT encoding" do
- IO.binread(@fname).encoding.should == Encoding::ASCII_8BIT
+ it "returns a String in BINARY encoding" do
+ IO.binread(@fname).encoding.should == Encoding::BINARY
end
- it "returns a String in ASCII-8BIT encoding regardless of Encoding.default_internal" do
+ it "returns a String in BINARY encoding regardless of Encoding.default_internal" do
Encoding.default_internal = Encoding::EUC_JP
- IO.binread(@fname).encoding.should == Encoding::ASCII_8BIT
+ IO.binread(@fname).encoding.should == Encoding::BINARY
end
it "raises an ArgumentError when not passed a valid length" do
diff --git a/spec/ruby/core/io/binwrite_spec.rb b/spec/ruby/core/io/binwrite_spec.rb
index e28ea8ebb1..8ebc86a52e 100644
--- a/spec/ruby/core/io/binwrite_spec.rb
+++ b/spec/ruby/core/io/binwrite_spec.rb
@@ -3,6 +3,4 @@ require_relative 'shared/binwrite'
describe "IO.binwrite" do
it_behaves_like :io_binwrite, :binwrite
-
- it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/io/external_encoding_spec.rb b/spec/ruby/core/io/external_encoding_spec.rb
index 3581019207..9666974647 100644
--- a/spec/ruby/core/io/external_encoding_spec.rb
+++ b/spec/ruby/core/io/external_encoding_spec.rb
@@ -171,9 +171,9 @@ describe "IO#external_encoding" do
end
describe "with 'rb' mode" do
- it "returns Encoding::ASCII_8BIT" do
+ it "returns Encoding::BINARY" do
@io = new_io @name, "rb"
- @io.external_encoding.should equal(Encoding::ASCII_8BIT)
+ @io.external_encoding.should equal(Encoding::BINARY)
end
it "returns the external encoding specified by the mode argument" do
@@ -191,9 +191,9 @@ describe "IO#external_encoding" do
end
describe "with 'wb' mode" do
- it "returns Encoding::ASCII_8BIT" do
+ it "returns Encoding::BINARY" do
@io = new_io @name, "wb"
- @io.external_encoding.should equal(Encoding::ASCII_8BIT)
+ @io.external_encoding.should equal(Encoding::BINARY)
end
it "returns the external encoding specified by the mode argument" do
diff --git a/spec/ruby/core/io/gets_spec.rb b/spec/ruby/core/io/gets_spec.rb
index ac763f2a13..371c1c3d3b 100644
--- a/spec/ruby/core/io/gets_spec.rb
+++ b/spec/ruby/core/io/gets_spec.rb
@@ -295,25 +295,25 @@ describe "IO#gets" do
end
it "overwrites the default external encoding with the IO object's own external encoding" do
- Encoding.default_external = Encoding::ASCII_8BIT
+ Encoding.default_external = Encoding::BINARY
Encoding.default_internal = Encoding::UTF_8
@io = new_io @name, 'r'
@io.set_encoding Encoding::IBM866
@io.gets.encoding.should == Encoding::UTF_8
end
- it "ignores the internal encoding if the default external encoding is ASCII-8BIT" do
- Encoding.default_external = Encoding::ASCII_8BIT
+ it "ignores the internal encoding if the default external encoding is BINARY" do
+ Encoding.default_external = Encoding::BINARY
Encoding.default_internal = Encoding::UTF_8
@io = new_io @name, 'r'
- @io.gets.encoding.should == Encoding::ASCII_8BIT
+ @io.gets.encoding.should == Encoding::BINARY
end
- it "transcodes to internal encoding if the IO object's external encoding is ASCII-8BIT" do
- Encoding.default_external = Encoding::ASCII_8BIT
+ it "transcodes to internal encoding if the IO object's external encoding is BINARY" do
+ Encoding.default_external = Encoding::BINARY
Encoding.default_internal = Encoding::UTF_8
@io = new_io @name, 'r'
- @io.set_encoding Encoding::ASCII_8BIT, Encoding::UTF_8
+ @io.set_encoding Encoding::BINARY, Encoding::UTF_8
@io.gets.encoding.should == Encoding::UTF_8
end
end
diff --git a/spec/ruby/core/io/internal_encoding_spec.rb b/spec/ruby/core/io/internal_encoding_spec.rb
index 772cdeeaaf..10ebf28707 100644
--- a/spec/ruby/core/io/internal_encoding_spec.rb
+++ b/spec/ruby/core/io/internal_encoding_spec.rb
@@ -82,14 +82,14 @@ describe :io_internal_encoding, shared: true do
@io.internal_encoding.should equal(Encoding::IBM437)
end
- it "returns nil when Encoding.default_external is ASCII-8BIT and the internal encoding is not set" do
- Encoding.default_external = Encoding::ASCII_8BIT
+ it "returns nil when Encoding.default_external is BINARY and the internal encoding is not set" do
+ Encoding.default_external = Encoding::BINARY
@io = new_io @name, @object
@io.internal_encoding.should be_nil
end
- it "returns nil when the external encoding is ASCII-8BIT and the internal encoding is not set" do
- @io = new_io @name, "#{@object}:ascii-8bit"
+ it "returns nil when the external encoding is BINARY and the internal encoding is not set" do
+ @io = new_io @name, "#{@object}:binary"
@io.internal_encoding.should be_nil
end
end
diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb
index ccb341a1f9..e005e14fdf 100644
--- a/spec/ruby/core/io/read_spec.rb
+++ b/spec/ruby/core/io/read_spec.rb
@@ -380,16 +380,16 @@ describe "IO#read in binary mode" do
result = File.open(@name, "rb") { |f| f.read }.chomp
- result.encoding.should == Encoding::ASCII_8BIT
+ result.encoding.should == Encoding::BINARY
xE2 = [226].pack('C*')
- result.should == ("abc" + xE2 + "def").force_encoding(Encoding::ASCII_8BIT)
+ result.should == ("abc" + xE2 + "def").force_encoding(Encoding::BINARY)
end
it "does not transcode file contents when an internal encoding is specified" do
result = File.open(@name, "r:binary:utf-8") { |f| f.read }.chomp
- result.encoding.should == Encoding::ASCII_8BIT
+ result.encoding.should == Encoding::BINARY
xE2 = [226].pack('C*')
- result.should == ("abc" + xE2 + "def").force_encoding(Encoding::ASCII_8BIT)
+ result.should == ("abc" + xE2 + "def").force_encoding(Encoding::BINARY)
end
end
@@ -420,37 +420,37 @@ describe "IO.read with BOM" do
it "reads a file without a bom" do
name = fixture __FILE__, "no_bom_UTF-8.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("ascii-8bit").should == "UTF-8\n"
+ result.force_encoding("binary").should == "UTF-8\n"
end
it "reads a file with a utf-8 bom" do
name = fixture __FILE__, "bom_UTF-8.txt"
result = File.read(name, mode: "rb:BOM|utf-16le")
- result.force_encoding("ascii-8bit").should == "UTF-8\n"
+ result.force_encoding("binary").should == "UTF-8\n"
end
it "reads a file with a utf-16le bom" do
name = fixture __FILE__, "bom_UTF-16LE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("ascii-8bit").should == "U\x00T\x00F\x00-\x001\x006\x00L\x00E\x00\n\x00"
+ result.force_encoding("binary").should == "U\x00T\x00F\x00-\x001\x006\x00L\x00E\x00\n\x00"
end
it "reads a file with a utf-16be bom" do
name = fixture __FILE__, "bom_UTF-16BE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("ascii-8bit").should == "\x00U\x00T\x00F\x00-\x001\x006\x00B\x00E\x00\n"
+ result.force_encoding("binary").should == "\x00U\x00T\x00F\x00-\x001\x006\x00B\x00E\x00\n"
end
it "reads a file with a utf-32le bom" do
name = fixture __FILE__, "bom_UTF-32LE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("ascii-8bit").should == "U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00L\x00\x00\x00E\x00\x00\x00\n\x00\x00\x00"
+ result.force_encoding("binary").should == "U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00L\x00\x00\x00E\x00\x00\x00\n\x00\x00\x00"
end
it "reads a file with a utf-32be bom" do
name = fixture __FILE__, "bom_UTF-32BE.txt"
result = File.read(name, mode: "rb:BOM|utf-8")
- result.force_encoding("ascii-8bit").should == "\x00\x00\x00U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00B\x00\x00\x00E\x00\x00\x00\n"
+ result.force_encoding("binary").should == "\x00\x00\x00U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00B\x00\x00\x00E\x00\x00\x00\n"
end
end
@@ -480,11 +480,11 @@ end
describe :io_read_size_internal_encoding, shared: true do
it "reads bytes when passed a size" do
- @io.read(2).should == [164, 162].pack('C*').force_encoding(Encoding::ASCII_8BIT)
+ @io.read(2).should == [164, 162].pack('C*').force_encoding(Encoding::BINARY)
end
- it "returns a String in ASCII-8BIT when passed a size" do
- @io.read(4).encoding.should equal(Encoding::ASCII_8BIT)
+ it "returns a String in BINARY when passed a size" do
+ @io.read(4).encoding.should equal(Encoding::BINARY)
end
it "does not change the buffer's encoding when passed a limit" do
diff --git a/spec/ruby/core/io/readbyte_spec.rb b/spec/ruby/core/io/readbyte_spec.rb
index f7653bf3bb..eb25975f58 100644
--- a/spec/ruby/core/io/readbyte_spec.rb
+++ b/spec/ruby/core/io/readbyte_spec.rb
@@ -21,6 +21,4 @@ describe "IO#readbyte" do
@io.readbyte
end.should raise_error EOFError
end
-
- it "needs to be reviewed for spec completeness"
end
diff --git a/spec/ruby/core/io/readlines_spec.rb b/spec/ruby/core/io/readlines_spec.rb
index 9e145f12f4..5a7e9b5aa8 100644
--- a/spec/ruby/core/io/readlines_spec.rb
+++ b/spec/ruby/core/io/readlines_spec.rb
@@ -201,10 +201,10 @@ describe "IO.readlines" do
lines.all? { |s| s.encoding == Encoding::UTF_16 }.should be_true
end
- it "ignores the default internal encoding if the external encoding is ASCII-8BIT" do
- Encoding.default_external = Encoding::ASCII_8BIT
+ it "ignores the default internal encoding if the external encoding is BINARY" do
+ Encoding.default_external = Encoding::BINARY
Encoding.default_internal = Encoding::UTF_8
lines = IO.readlines(@name)
- lines.all? { |s| s.encoding == Encoding::ASCII_8BIT }.should be_true
+ lines.all? { |s| s.encoding == Encoding::BINARY }.should be_true
end
end
diff --git a/spec/ruby/core/io/readpartial_spec.rb b/spec/ruby/core/io/readpartial_spec.rb
index 53160ca337..1ab01dcf49 100644
--- a/spec/ruby/core/io/readpartial_spec.rb
+++ b/spec/ruby/core/io/readpartial_spec.rb
@@ -1,4 +1,4 @@
-# -*- encoding: ascii-8bit -*-
+# -*- encoding: binary -*-
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/core/io/set_encoding_spec.rb b/spec/ruby/core/io/set_encoding_spec.rb
index a9d783325c..5aec6a96c3 100644
--- a/spec/ruby/core/io/set_encoding_spec.rb
+++ b/spec/ruby/core/io/set_encoding_spec.rb
@@ -87,7 +87,7 @@ describe "IO#set_encoding when passed nil, nil" do
describe "with 'rb' mode" do
it "returns Encoding.default_external" do
@io = new_io @name, "rb"
- @io.external_encoding.should equal(Encoding::ASCII_8BIT)
+ @io.external_encoding.should equal(Encoding::BINARY)
@io.set_encoding nil, nil
@io.external_encoding.should equal(Encoding.default_external)
diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb
index ea22f40090..f6069a4cdc 100644
--- a/spec/ruby/core/io/shared/new.rb
+++ b/spec/ruby/core/io/shared/new.rb
@@ -168,13 +168,13 @@ describe :io_new, shared: true do
it "sets external encoding to binary with binmode in mode string" do
@io = IO.send(@method, @fd, 'wb')
- @io.external_encoding.to_s.should == 'ASCII-8BIT'
+ @io.external_encoding.should == Encoding::BINARY
end
# #5917
it "sets external encoding to binary with :binmode option" do
@io = IO.send(@method, @fd, 'w', {binmode: true})
- @io.external_encoding.to_s.should == 'ASCII-8BIT'
+ @io.external_encoding.should == Encoding::BINARY
end
it "does not use binary encoding when mode encoding is specified" do
diff --git a/spec/ruby/core/io/write_spec.rb b/spec/ruby/core/io/write_spec.rb
index 5fb3941505..5fb5cc7013 100644
--- a/spec/ruby/core/io/write_spec.rb
+++ b/spec/ruby/core/io/write_spec.rb
@@ -70,7 +70,7 @@ describe "IO#write on a file" do
ë = ([235].pack('U')).encode('ISO-8859-1')
ö = ([246].pack('U')).encode('ISO-8859-1')
res = "H#{ë}ll#{ö}"
- File.binread(@filename).should == res.force_encoding(Encoding::ASCII_8BIT)
+ File.binread(@filename).should == res.force_encoding(Encoding::BINARY)
end
end
@@ -94,7 +94,7 @@ describe "IO.write" do
IO.write(@filename, 'Hëllö'.encode('ISO-8859-1'))
xEB = [235].pack('C*')
xF6 = [246].pack('C*')
- File.binread(@filename).should == ("H" + xEB + "ll" + xF6).force_encoding(Encoding::ASCII_8BIT)
+ File.binread(@filename).should == ("H" + xEB + "ll" + xF6).force_encoding(Encoding::BINARY)
end
platform_is_not :windows do