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/downcase_spec.rb | |
parent | 00c33d9c232ed1a79eda17acd7231ac93caa162b (diff) |
Update to ruby/spec@15c9619
Diffstat (limited to 'spec/ruby/core/string/downcase_spec.rb')
-rw-r--r-- | spec/ruby/core/string/downcase_spec.rb | 214 |
1 files changed, 98 insertions, 116 deletions
diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index 9fb93902b1..241bd8c147 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -8,82 +8,66 @@ describe "String#downcase" do "hello".downcase.should == "hello" end - ruby_version_is ''...'2.4' do - it "is locale insensitive (only replaces A-Z)" do - "ÄÖÜ".downcase.should == "ÄÖÜ" + describe "full Unicode case mapping" do + it "works for all of Unicode with no option" do + "ÄÖÜ".downcase.should == "äöü" + end - str = Array.new(256) { |c| c.chr }.join - expected = Array.new(256) do |i| - c = i.chr - c.between?("A", "Z") ? c.downcase : c - end.join + it "updates string metadata" do + downcased = "\u{212A}ING".downcase - str.downcase.should == expected + downcased.should == "king" + downcased.size.should == 4 + downcased.bytesize.should == 4 + downcased.ascii_only?.should be_true end end - ruby_version_is '2.4' do - describe "full Unicode case mapping" do - it "works for all of Unicode with no option" do - "ÄÖÜ".downcase.should == "äöü" - end - - it "updates string metadata" do - downcased = "\u{212A}ING".downcase - - downcased.should == "king" - downcased.size.should == 4 - downcased.bytesize.should == 4 - downcased.ascii_only?.should be_true - end + describe "ASCII-only case mapping" do + it "does not downcase non-ASCII characters" do + "CÅR".downcase(:ascii).should == "cÅr" end + end - describe "ASCII-only case mapping" do - it "does not downcase non-ASCII characters" do - "CÅR".downcase(:ascii).should == "cÅr" - end + describe "full Unicode case mapping adapted for Turkic languages" do + it "downcases characters according to Turkic semantics" do + "İ".downcase(:turkic).should == "i" end - describe "full Unicode case mapping adapted for Turkic languages" do - it "downcases characters according to Turkic semantics" do - "İ".downcase(:turkic).should == "i" - end - - it "allows Lithuanian as an extra option" do - "İ".downcase(:turkic, :lithuanian).should == "i" - end - - it "does not allow any other additional option" do - lambda { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError) - end + it "allows Lithuanian as an extra option" do + "İ".downcase(:turkic, :lithuanian).should == "i" end - describe "full Unicode case mapping adapted for Lithuanian" do - it "currently works the same as full Unicode case mapping" do - "İS".downcase(:lithuanian).should == "i\u{307}s" - end + it "does not allow any other additional option" do + lambda { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError) + end + end - it "allows Turkic as an extra option (and applies Turkic semantics)" do - "İS".downcase(:lithuanian, :turkic).should == "is" - end + describe "full Unicode case mapping adapted for Lithuanian" do + it "currently works the same as full Unicode case mapping" do + "İS".downcase(:lithuanian).should == "i\u{307}s" + end - it "does not allow any other additional option" do - lambda { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) - end + it "allows Turkic as an extra option (and applies Turkic semantics)" do + "İS".downcase(:lithuanian, :turkic).should == "is" end - describe "case folding" do - it "case folds special characters" do - "ß".downcase.should == "ß" - "ß".downcase(:fold).should == "ss" - end + it "does not allow any other additional option" do + lambda { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) end + end - it "does not allow invalid options" do - lambda { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) + describe "case folding" do + it "case folds special characters" do + "ß".downcase.should == "ß" + "ß".downcase(:fold).should == "ss" end end + it "does not allow invalid options" do + lambda { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) + end + it "taints result when self is tainted" do "".taint.downcase.tainted?.should == true "x".taint.downcase.tainted?.should == true @@ -102,83 +86,81 @@ describe "String#downcase!" 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.downcase! - a.should == "äöü" - end + describe "full Unicode case mapping" do + it "modifies self in place for all of Unicode with no option" do + a = "ÄÖÜ" + a.downcase! + a.should == "äöü" + end - it "updates string metadata" do - downcased = "\u{212A}ING" - downcased.downcase! + it "updates string metadata" do + downcased = "\u{212A}ING" + downcased.downcase! - downcased.should == "king" - downcased.size.should == 4 - downcased.bytesize.should == 4 - downcased.ascii_only?.should be_true - end + downcased.should == "king" + downcased.size.should == 4 + downcased.bytesize.should == 4 + downcased.ascii_only?.should be_true end + end - describe "ASCII-only case mapping" do - it "does not downcase non-ASCII characters" do - a = "CÅR" - a.downcase!(:ascii) - a.should == "cÅr" - end + describe "ASCII-only case mapping" do + it "does not downcase non-ASCII characters" do + a = "CÅR" + a.downcase!(:ascii) + a.should == "cÅr" end + end - describe "full Unicode case mapping adapted for Turkic languages" do - it "downcases characters according to Turkic semantics" do - a = "İ" - a.downcase!(:turkic) - a.should == "i" - end + describe "full Unicode case mapping adapted for Turkic languages" do + it "downcases characters according to Turkic semantics" do + a = "İ" + a.downcase!(:turkic) + a.should == "i" + end - it "allows Lithuanian as an extra option" do - a = "İ" - a.downcase!(:turkic, :lithuanian) - a.should == "i" - end + it "allows Lithuanian as an extra option" do + a = "İ" + a.downcase!(:turkic, :lithuanian) + a.should == "i" + end - it "does not allow any other additional option" do - lambda { a = "İ"; a.downcase!(:turkic, :ascii) }.should raise_error(ArgumentError) - end + it "does not allow any other additional option" do + lambda { a = "İ"; a.downcase!(: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 = "İS" - a.downcase!(:lithuanian) - a.should == "i\u{307}s" - end + describe "full Unicode case mapping adapted for Lithuanian" do + it "currently works the same as full Unicode case mapping" do + a = "İS" + a.downcase!(:lithuanian) + a.should == "i\u{307}s" + end - it "allows Turkic as an extra option (and applies Turkic semantics)" do - a = "İS" - a.downcase!(:lithuanian, :turkic) - a.should == "is" - end + it "allows Turkic as an extra option (and applies Turkic semantics)" do + a = "İS" + a.downcase!(:lithuanian, :turkic) + a.should == "is" + end - it "does not allow any other additional option" do - lambda { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) - end + it "does not allow any other additional option" do + lambda { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) end + end - describe "case folding" do - it "case folds special characters" do - a = "ß" - a.downcase! - a.should == "ß" + describe "case folding" do + it "case folds special characters" do + a = "ß" + a.downcase! + a.should == "ß" - a.downcase!(:fold) - a.should == "ss" - end + a.downcase!(:fold) + a.should == "ss" end + end - it "does not allow invalid options" do - lambda { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError) - end + it "does not allow invalid options" do + lambda { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError) end it "returns nil if no modifications were made" do |