mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@4bb0f25
* Specs added by TruffleRuby. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5b55eaa00d
commit
b46da8d84e
24 changed files with 812 additions and 57 deletions
|
@ -23,8 +23,61 @@ describe "String#swapcase" do
|
|||
end
|
||||
|
||||
ruby_version_is '2.4' do
|
||||
it "works for all of Unicode" do
|
||||
"äÖü".swapcase.should == "ÄöÜ"
|
||||
describe "full Unicode case mapping" do
|
||||
it "works for all of Unicode with no option" do
|
||||
"äÖü".swapcase.should == "ÄöÜ"
|
||||
end
|
||||
|
||||
it "updates string metadata" do
|
||||
swapcased = "Aßet".swapcase
|
||||
|
||||
swapcased.should == "aSSET"
|
||||
swapcased.size.should == 5
|
||||
swapcased.bytesize.should == 5
|
||||
swapcased.ascii_only?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "ASCII-only case mapping" do
|
||||
it "does not swapcase non-ASCII characters" do
|
||||
"aßet".swapcase(:ascii).should == "AßET"
|
||||
end
|
||||
end
|
||||
|
||||
describe "full Unicode case mapping adapted for Turkic languages" do
|
||||
it "swaps case of ASCII characters according to Turkic semantics" do
|
||||
"aiS".swapcase(:turkic).should == "Aİs"
|
||||
end
|
||||
|
||||
it "allows Lithuanian as an extra option" do
|
||||
"aiS".swapcase(:turkic, :lithuanian).should == "Aİs"
|
||||
end
|
||||
|
||||
it "does not allow any other additional option" do
|
||||
lambda { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "full Unicode case mapping adapted for Lithuanian" do
|
||||
it "currently works the same as full Unicode case mapping" do
|
||||
"Iß".swapcase(:lithuanian).should == "iSS"
|
||||
end
|
||||
|
||||
it "allows Turkic as an extra option (and applies Turkic semantics)" do
|
||||
"iS".swapcase(:lithuanian, :turkic).should == "İs"
|
||||
end
|
||||
|
||||
it "does not allow any other additional option" do
|
||||
lambda { "aiS".swapcase(:lithuanian, :ascii) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not allow the :fold option for upcasing" do
|
||||
lambda { "abc".swapcase(:fold) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not allow invalid options" do
|
||||
lambda { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,10 +95,74 @@ describe "String#swapcase!" do
|
|||
end
|
||||
|
||||
ruby_version_is '2.4' do
|
||||
it "modifies self in place for all of Unicode" do
|
||||
a = "äÖü"
|
||||
a.swapcase!.should equal(a)
|
||||
a.should == "ÄöÜ"
|
||||
describe "full Unicode case mapping" do
|
||||
it "modifies self in place for all of Unicode with no option" do
|
||||
a = "äÖü"
|
||||
a.swapcase!
|
||||
a.should == "ÄöÜ"
|
||||
end
|
||||
|
||||
it "updates string metadata" do
|
||||
swapcased = "Aßet"
|
||||
swapcased.swapcase!
|
||||
|
||||
swapcased.should == "aSSET"
|
||||
swapcased.size.should == 5
|
||||
swapcased.bytesize.should == 5
|
||||
swapcased.ascii_only?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "modifies self in place for ASCII-only case mapping" do
|
||||
it "does not swapcase non-ASCII characters" do
|
||||
a = "aßet"
|
||||
a.swapcase!(:ascii)
|
||||
a.should == "AßET"
|
||||
end
|
||||
end
|
||||
|
||||
describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do
|
||||
it "swaps case of ASCII characters according to Turkic semantics" do
|
||||
a = "aiS"
|
||||
a.swapcase!(:turkic)
|
||||
a.should == "Aİs"
|
||||
end
|
||||
|
||||
it "allows Lithuanian as an extra option" do
|
||||
a = "aiS"
|
||||
a.swapcase!(:turkic, :lithuanian)
|
||||
a.should == "Aİs"
|
||||
end
|
||||
|
||||
it "does not allow any other additional option" do
|
||||
lambda { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "full Unicode case mapping adapted for Lithuanian" do
|
||||
it "currently works the same as full Unicode case mapping" do
|
||||
a = "Iß"
|
||||
a.swapcase!(:lithuanian)
|
||||
a.should == "iSS"
|
||||
end
|
||||
|
||||
it "allows Turkic as an extra option (and applies Turkic semantics)" do
|
||||
a = "iS"
|
||||
a.swapcase!(:lithuanian, :turkic)
|
||||
a.should == "İs"
|
||||
end
|
||||
|
||||
it "does not allow any other additional option" do
|
||||
lambda { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not allow the :fold option for upcasing" do
|
||||
lambda { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not allow invalid options" do
|
||||
lambda { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue