Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh specs for String#encoding #2158

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions spec/core/string/encoding_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
end

it "returns the given encoding if #force_encoding has been called" do
"a".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"a".dup.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
end

it "returns the given encoding if #encode!has been called" do
"a".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"a".dup.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
end
end

Expand Down Expand Up @@ -108,14 +108,14 @@
end

it "returns the given encoding if #force_encoding has been called" do
"\u{20}".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"\u{2020}".force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"\u{20}".dup.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"\u{2020}".dup.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
end

it "returns the given encoding if #encode!has been called" do
"\u{20}".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"\u{20}".dup.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
# NATFIXME: NOT YET IMPLEMENTED in src/encoding/shiftjis_encoding_object.cpp#61: Conversion above Unicode Basic Latin (0x00..0x7F) not implemented
# "\u{2020}".encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
# "\u{2020}".dup.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
end
end

Expand Down Expand Up @@ -174,16 +174,12 @@
end

it "returns the given encoding if #force_encoding has been called" do
x50 = "\x50"
x50.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
xD4 = [212].pack('C')
xD4.force_encoding(Encoding::ISO_8859_9).encoding.should == Encoding::ISO_8859_9
"\x50".dup.force_encoding(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
[212].pack('C').force_encoding(Encoding::ISO_8859_9).encoding.should == Encoding::ISO_8859_9
end

it "returns the given encoding if #encode!has been called" do
x50 = "\x50"
x50.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
x00 = "x\00"
x00.encode!(Encoding::UTF_8).encoding.should == Encoding::UTF_8
"\x50".dup.encode!(Encoding::SHIFT_JIS).encoding.should == Encoding::SHIFT_JIS
"x\00".dup.encode!(Encoding::UTF_8).encoding.should == Encoding::UTF_8
end
end
Loading