diff options
Diffstat (limited to 'spec/ruby/core/string/casecmp_spec.rb')
-rw-r--r-- | spec/ruby/core/string/casecmp_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb index 9e89e1314d..87be999964 100644 --- a/spec/ruby/core/string/casecmp_spec.rb +++ b/spec/ruby/core/string/casecmp_spec.rb @@ -37,6 +37,10 @@ describe "String#casecmp independent of case" do end end + it "returns nil if incompatible encodings" do + "あれ".casecmp("れ".encode(Encoding::EUC_JP)).should be_nil + end + describe "in UTF-8 mode" do describe "for non-ASCII characters" do before :each do @@ -96,6 +100,12 @@ describe "String#casecmp independent of case" do it "returns 1 when numerically greater than other" do @lower_a_tilde.casecmp(@upper_a_tilde).should == 1 end + + ruby_version_is "2.4" do + it "does not case fold" do + "ß".casecmp("ss").should == 1 + end + end end describe "when comparing a subclass instance" do @@ -138,6 +148,10 @@ ruby_version_is "2.4" do "abc".casecmp?(other).should == true end + it "returns nil if incompatible encodings" do + "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should be_nil + end + describe 'for UNICODE characters' do it 'returns true when downcase(:fold) on unicode' do 'äöü'.casecmp?('ÄÖÜ').should == true @@ -181,6 +195,12 @@ ruby_version_is "2.4" do end end + ruby_version_is "2.4" do + it "case folds" do + "ß".casecmp?("ss").should be_true + end + end + ruby_version_is "2.4" ... "2.5" do it "raises a TypeError if other can't be converted to a string" do lambda { "abc".casecmp?(mock('abc')) }.should raise_error(TypeError) |