diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-13 21:58:54 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-13 21:58:54 +0000 |
commit | b46da8d84efeb97cb52ba0560d5b149ccda0d561 (patch) | |
tree | 382ba848ef97215f1a5ec991727db3ed7f90973c /spec/ruby/core/string/upcase_spec.rb | |
parent | 5b55eaa00db05004d1a6b74c3aaa5e680fc73235 (diff) |
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
Diffstat (limited to 'spec/ruby/core/string/upcase_spec.rb')
-rw-r--r-- | spec/ruby/core/string/upcase_spec.rb | 130 |
1 files changed, 123 insertions, 7 deletions
diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb index 001cf1f495..347f567be9 100644 --- a/spec/ruby/core/string/upcase_spec.rb +++ b/spec/ruby/core/string/upcase_spec.rb @@ -23,8 +23,61 @@ describe "String#upcase" do end ruby_version_is '2.4' do - it "works for all of Unicode" do - "äöü".upcase.should == "ÄÖÜ" + describe "full Unicode case mapping" do + it "works for all of Unicode with no option" do + "äöü".upcase.should == "ÄÖÜ" + end + + it "updates string metadata" do + upcased = "aßet".upcase + + upcased.should == "ASSET" + upcased.size.should == 5 + upcased.bytesize.should == 5 + upcased.ascii_only?.should be_true + end + end + + describe "ASCII-only case mapping" do + it "does not upcase non-ASCII characters" do + "aßet".upcase(:ascii).should == "AßET" + end + end + + describe "full Unicode case mapping adapted for Turkic languages" do + it "upcases ASCII characters according to Turkic semantics" do + "i".upcase(:turkic).should == "İ" + end + + it "allows Lithuanian as an extra option" do + "i".upcase(:turkic, :lithuanian).should == "İ" + end + + it "does not allow any other additional option" do + lambda { "i".upcase(: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ß".upcase(:lithuanian).should == "ISS" + end + + it "allows Turkic as an extra option (and applies Turkic semantics)" do + "iß".upcase(:lithuanian, :turkic).should == "İSS" + end + + it "does not allow any other additional option" do + lambda { "iß".upcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + end + end + + it "does not allow the :fold option for upcasing" do + lambda { "abc".upcase(:fold) }.should raise_error(ArgumentError) + end + + it "does not allow invalid options" do + lambda { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError) end end @@ -46,12 +99,75 @@ describe "String#upcase!" do a.should == "HELLO" end - ruby_version_is '2.4' do - it "modifies self in place for all of Unicode" do - a = "äöü" - a.upcase!.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.upcase! + a.should == "ÄÖÜ" + end + + it "updates string metadata for self" do + upcased = "aßet" + upcased.upcase! + + upcased.should == "ASSET" + upcased.size.should == 5 + upcased.bytesize.should == 5 + upcased.ascii_only?.should be_true + end + end + + describe "modifies self in place for ASCII-only case mapping" do + it "does not upcase non-ASCII characters" do + a = "aßet" + a.upcase!(:ascii) + a.should == "AßET" + end + end + + describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do + it "upcases ASCII characters according to Turkic semantics" do + a = "i" + a.upcase!(:turkic) + a.should == "İ" + end + + it "allows Lithuanian as an extra option" do + a = "i" + a.upcase!(:turkic, :lithuanian) + a.should == "İ" + end + + it "does not allow any other additional option" do + lambda { a = "i"; a.upcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + end + end + + describe "modifies self in place for full Unicode case mapping adapted for Lithuanian" do + it "currently works the same as full Unicode case mapping" do + a = "iß" + a.upcase!(:lithuanian) + a.should == "ISS" + end + + it "allows Turkic as an extra option (and applies Turkic semantics)" do + a = "iß" + a.upcase!(:lithuanian, :turkic) + a.should == "İSS" + end + + it "does not allow any other additional option" do + lambda { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + end + end + + it "does not allow the :fold option for upcasing" do + lambda { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError) + end + + it "does not allow invalid options" do + lambda { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError) end end |