summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLars Kanis <kanis@comcard.de>2021-08-16 13:11:30 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-22 10:33:22 +0900
commit6594623f623a0982da62cc105094da0701d499da (patch)
tree75d34cda3a7c66ed4ce62bbe2f172876b0bbdcdd /spec
parentc527d278a3dd94b9f5b82769fb69ee7b92b6d6a9 (diff)
Fix Marshal.dump(closed_io) to raise TypeError and allow encoding on closed IO
Mashalling a closed IO object raised "closed stream (IOError)" before instead of TypeError. This changes IO#(in|ex)ternal_encoding to still return the encoding even if the underlying FD is closed. Fixes bug #18077
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4758
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/io/external_encoding_spec.rb6
-rw-r--r--spec/ruby/core/io/internal_encoding_spec.rb6
2 files changed, 8 insertions, 4 deletions
diff --git a/spec/ruby/core/io/external_encoding_spec.rb b/spec/ruby/core/io/external_encoding_spec.rb
index c1b727d930..25af11f686 100644
--- a/spec/ruby/core/io/external_encoding_spec.rb
+++ b/spec/ruby/core/io/external_encoding_spec.rb
@@ -94,8 +94,10 @@ describe "IO#external_encoding" do
rm_r @name
end
- it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.external_encoding }.should raise_error(IOError)
+ ruby_version_is '3.1' do
+ it "can be retrieved from a closed stream" do
+ IOSpecs.closed_io.external_encoding.should equal(Encoding.default_external)
+ end
end
describe "with 'r' mode" do
diff --git a/spec/ruby/core/io/internal_encoding_spec.rb b/spec/ruby/core/io/internal_encoding_spec.rb
index 210e969c7b..c76c9c8508 100644
--- a/spec/ruby/core/io/internal_encoding_spec.rb
+++ b/spec/ruby/core/io/internal_encoding_spec.rb
@@ -113,8 +113,10 @@ describe "IO#internal_encoding" do
Encoding.default_internal = @internal
end
- it "raises an IOError on closed stream" do
- -> { IOSpecs.closed_io.internal_encoding }.should raise_error(IOError)
+ ruby_version_is '3.1' do
+ it "can be retrieved from a closed stream" do
+ IOSpecs.closed_io.internal_encoding.should equal(Encoding.default_internal)
+ end
end
describe "with 'r' mode" do