mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@7de852d
This commit is contained in:
parent
994833085a
commit
79671ec57e
135 changed files with 4415 additions and 4885 deletions
|
@ -87,30 +87,28 @@ describe "String#ljust with length, padding" do
|
|||
"hello".ljust(6, 'X'.taint).tainted?.should be_true
|
||||
end
|
||||
|
||||
with_feature :encoding do
|
||||
describe "with width" do
|
||||
it "returns a String in the same encoding as the original" do
|
||||
str = "abc".force_encoding Encoding::IBM437
|
||||
result = str.ljust 5
|
||||
result.should == "abc "
|
||||
result.encoding.should equal(Encoding::IBM437)
|
||||
end
|
||||
describe "with width" do
|
||||
it "returns a String in the same encoding as the original" do
|
||||
str = "abc".force_encoding Encoding::IBM437
|
||||
result = str.ljust 5
|
||||
result.should == "abc "
|
||||
result.encoding.should equal(Encoding::IBM437)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with width, pattern" do
|
||||
it "returns a String in the compatible encoding" do
|
||||
str = "abc".force_encoding Encoding::IBM437
|
||||
result = str.ljust 5, "あ"
|
||||
result.should == "abcああ"
|
||||
result.encoding.should equal(Encoding::UTF_8)
|
||||
end
|
||||
|
||||
describe "with width, pattern" do
|
||||
it "returns a String in the compatible encoding" do
|
||||
str = "abc".force_encoding Encoding::IBM437
|
||||
result = str.ljust 5, "あ"
|
||||
result.should == "abcああ"
|
||||
result.encoding.should equal(Encoding::UTF_8)
|
||||
end
|
||||
|
||||
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
|
||||
pat = "ア".encode Encoding::EUC_JP
|
||||
lambda do
|
||||
"あれ".ljust 5, pat
|
||||
end.should raise_error(Encoding::CompatibilityError)
|
||||
end
|
||||
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
|
||||
pat = "ア".encode Encoding::EUC_JP
|
||||
lambda do
|
||||
"あれ".ljust 5, pat
|
||||
end.should raise_error(Encoding::CompatibilityError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue