diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-04-27 18:53:23 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-04-27 18:53:23 +0200 |
commit | a1b4816759418ca8fe510e8739622fc5d77ab0f0 (patch) | |
tree | 9d4fb6091d0086817f5bde46bf1150e9130d34fd /spec/ruby/core/string/capitalize_spec.rb | |
parent | 00c33d9c232ed1a79eda17acd7231ac93caa162b (diff) | |
download | ruby-a1b4816759418ca8fe510e8739622fc5d77ab0f0.tar.gz |
Update to ruby/spec@15c9619
Diffstat (limited to 'spec/ruby/core/string/capitalize_spec.rb')
-rw-r--r-- | spec/ruby/core/string/capitalize_spec.rb | 212 |
1 files changed, 100 insertions, 112 deletions
diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb index 10f9ab00a1..c7f4aed20c 100644 --- a/spec/ruby/core/string/capitalize_spec.rb +++ b/spec/ruby/core/string/capitalize_spec.rb @@ -17,77 +17,67 @@ describe "String#capitalize" do "hello".taint.capitalize.tainted?.should == true end - ruby_version_is ''...'2.4' do - it "is locale insensitive (only upcases a-z and only downcases A-Z)" do - "ÄÖÜ".capitalize.should == "ÄÖÜ" - "ärger".capitalize.should == "ärger" - "BÄR".capitalize.should == "BÄr" + describe "full Unicode case mapping" do + it "works for all of Unicode with no option" do + "äöÜ".capitalize.should == "Äöü" end - end - - ruby_version_is '2.4' do - describe "full Unicode case mapping" do - it "works for all of Unicode with no option" do - "äöÜ".capitalize.should == "Äöü" - end - it "only capitalizes the first resulting character when upcasing a character produces a multi-character sequence" do - "ß".capitalize.should == "Ss" - end + it "only capitalizes the first resulting character when upcasing a character produces a multi-character sequence" do + "ß".capitalize.should == "Ss" + end - it "updates string metadata" do - capitalized = "ßeT".capitalize + it "updates string metadata" do + capitalized = "ßeT".capitalize - capitalized.should == "Sset" - capitalized.size.should == 4 - capitalized.bytesize.should == 4 - capitalized.ascii_only?.should be_true - end + capitalized.should == "Sset" + capitalized.size.should == 4 + capitalized.bytesize.should == 4 + capitalized.ascii_only?.should be_true end + end - describe "ASCII-only case mapping" do - it "does not capitalize non-ASCII characters" do - "ßet".capitalize(:ascii).should == "ßet" - end + describe "ASCII-only case mapping" do + it "does not capitalize non-ASCII characters" do + "ßet".capitalize(:ascii).should == "ßet" end + end - describe "full Unicode case mapping adapted for Turkic languages" do - it "capitalizes ASCII characters according to Turkic semantics" do - "iSa".capitalize(:turkic).should == "İsa" - end - - it "allows Lithuanian as an extra option" do - "iSa".capitalize(:turkic, :lithuanian).should == "İsa" - end - - it "does not allow any other additional option" do - lambda { "iSa".capitalize(:turkic, :ascii) }.should raise_error(ArgumentError) - end + describe "full Unicode case mapping adapted for Turkic languages" do + it "capitalizes ASCII characters according to Turkic semantics" do + "iSa".capitalize(:turkic).should == "İsa" end - describe "full Unicode case mapping adapted for Lithuanian" do - it "currently works the same as full Unicode case mapping" do - "iß".capitalize(:lithuanian).should == "Iß" - end + it "allows Lithuanian as an extra option" do + "iSa".capitalize(:turkic, :lithuanian).should == "İsa" + end - it "allows Turkic as an extra option (and applies Turkic semantics)" do - "iß".capitalize(:lithuanian, :turkic).should == "İß" - end + it "does not allow any other additional option" do + lambda { "iSa".capitalize(:turkic, :ascii) }.should raise_error(ArgumentError) + end + end - it "does not allow any other additional option" do - lambda { "iß".capitalize(:lithuanian, :ascii) }.should raise_error(ArgumentError) - end + describe "full Unicode case mapping adapted for Lithuanian" do + it "currently works the same as full Unicode case mapping" do + "iß".capitalize(:lithuanian).should == "Iß" end - it "does not allow the :fold option for upcasing" do - lambda { "abc".capitalize(:fold) }.should raise_error(ArgumentError) + it "allows Turkic as an extra option (and applies Turkic semantics)" do + "iß".capitalize(:lithuanian, :turkic).should == "İß" end - it "does not allow invalid options" do - lambda { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError) + it "does not allow any other additional option" do + lambda { "iß".capitalize(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end + it "does not allow the :fold option for upcasing" do + lambda { "abc".capitalize(:fold) }.should raise_error(ArgumentError) + end + + it "does not allow invalid options" do + lambda { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError) + end + it "returns subclass instances when called on a subclass" do StringSpecs::MyString.new("hello").capitalize.should be_an_instance_of(StringSpecs::MyString) StringSpecs::MyString.new("Hello").capitalize.should be_an_instance_of(StringSpecs::MyString) @@ -101,84 +91,82 @@ describe "String#capitalize!" do a.should == "Hello" end - ruby_version_is '2.4' do - describe "full Unicode case mapping" do - it "modifies self in place for all of Unicode with no option" do - a = "äöÜ" - a.capitalize! - a.should == "Äöü" - end + describe "full Unicode case mapping" do + it "modifies self in place for all of Unicode with no option" do + a = "äöÜ" + a.capitalize! + a.should == "Äöü" + end - it "only capitalizes the first resulting character when upcasing a character produces a multi-character sequence" do - a = "ß" - a.capitalize! - a.should == "Ss" - end + it "only capitalizes the first resulting character when upcasing a character produces a multi-character sequence" do + a = "ß" + a.capitalize! + a.should == "Ss" + end - it "updates string metadata" do - capitalized = "ßeT" - capitalized.capitalize! + it "updates string metadata" do + capitalized = "ßeT" + capitalized.capitalize! - capitalized.should == "Sset" - capitalized.size.should == 4 - capitalized.bytesize.should == 4 - capitalized.ascii_only?.should be_true - end + capitalized.should == "Sset" + capitalized.size.should == 4 + capitalized.bytesize.should == 4 + capitalized.ascii_only?.should be_true end + end - describe "modifies self in place for ASCII-only case mapping" do - it "does not capitalize non-ASCII characters" do - a = "ßet" - a.capitalize!(:ascii) - a.should == "ßet" - end + describe "modifies self in place for ASCII-only case mapping" do + it "does not capitalize non-ASCII characters" do + a = "ßet" + a.capitalize!(:ascii) + a.should == "ßet" end + end - describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do - it "capitalizes ASCII characters according to Turkic semantics" do - a = "iSa" - a.capitalize!(:turkic) - a.should == "İsa" - end - - it "allows Lithuanian as an extra option" do - a = "iSa" - a.capitalize!(:turkic, :lithuanian) - a.should == "İsa" - end - - it "does not allow any other additional option" do - lambda { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should raise_error(ArgumentError) - end + describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do + it "capitalizes ASCII characters according to Turkic semantics" do + a = "iSa" + a.capitalize!(:turkic) + a.should == "İsa" 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.capitalize!(:lithuanian) - a.should == "Iß" - end + it "allows Lithuanian as an extra option" do + a = "iSa" + a.capitalize!(:turkic, :lithuanian) + a.should == "İsa" + end - it "allows Turkic as an extra option (and applies Turkic semantics)" do - a = "iß" - a.capitalize!(:lithuanian, :turkic) - a.should == "İß" - end + it "does not allow any other additional option" do + lambda { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should raise_error(ArgumentError) + end + end - it "does not allow any other additional option" do - lambda { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should raise_error(ArgumentError) - 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.capitalize!(:lithuanian) + a.should == "Iß" end - it "does not allow the :fold option for upcasing" do - lambda { a = "abc"; a.capitalize!(:fold) }.should raise_error(ArgumentError) + it "allows Turkic as an extra option (and applies Turkic semantics)" do + a = "iß" + a.capitalize!(:lithuanian, :turkic) + a.should == "İß" end - it "does not allow invalid options" do - lambda { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError) + it "does not allow any other additional option" do + lambda { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end + it "does not allow the :fold option for upcasing" do + lambda { a = "abc"; a.capitalize!(:fold) }.should raise_error(ArgumentError) + end + + it "does not allow invalid options" do + lambda { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError) + end + it "returns nil when no changes are made" do a = "Hello" a.capitalize!.should == nil |