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/symbol | |
parent | 00c33d9c232ed1a79eda17acd7231ac93caa162b (diff) | |
download | ruby-a1b4816759418ca8fe510e8739622fc5d77ab0f0.tar.gz |
Update to ruby/spec@15c9619
Diffstat (limited to 'spec/ruby/core/symbol')
-rw-r--r-- | spec/ruby/core/symbol/capitalize_spec.rb | 21 | ||||
-rw-r--r-- | spec/ruby/core/symbol/casecmp_spec.rb | 136 | ||||
-rw-r--r-- | spec/ruby/core/symbol/downcase_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/core/symbol/dup_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/symbol/match_spec.rb | 64 | ||||
-rw-r--r-- | spec/ruby/core/symbol/swapcase_spec.rb | 18 | ||||
-rw-r--r-- | spec/ruby/core/symbol/upcase_spec.rb | 14 |
7 files changed, 109 insertions, 166 deletions
diff --git a/spec/ruby/core/symbol/capitalize_spec.rb b/spec/ruby/core/symbol/capitalize_spec.rb index 54aebf21ca..a84bcf280a 100644 --- a/spec/ruby/core/symbol/capitalize_spec.rb +++ b/spec/ruby/core/symbol/capitalize_spec.rb @@ -14,18 +14,9 @@ describe "Symbol#capitalize" do :"£1.20".capitalize.should == :"£1.20" end - ruby_version_is ''...'2.4' do - it "leaves the first character alone if it is not an alphabetical ASCII character" do - "\u{00DE}c".to_sym.capitalize.should == :"Þc" - "\u{00DF}C".to_sym.capitalize.should == :"ßc" - end - end - - ruby_version_is '2.4' do - it "capitalizes the first character if it is Unicode" do - :"äöü".capitalize.should == :"Äöü" - :"aou".capitalize.should == :"Aou" - end + it "capitalizes the first character if it is Unicode" do + :"äöü".capitalize.should == :"Äöü" + :"aou".capitalize.should == :"Aou" end it "converts subsequent uppercase ASCII characters to their lowercase equivalents" do @@ -40,12 +31,6 @@ describe "Symbol#capitalize" do :mIxEd.capitalize.should == :Mixed end - ruby_version_is ''...'2.4' do - it "leaves uppercase Unicode characters as they were" do - "a\u{00DE}c".to_sym.capitalize.should == :"AÞc" - end - end - it "leaves lowercase Unicode characters (except in first position) as they were" do "a\u{00DF}C".to_sym.capitalize.should == :"Aßc" end diff --git a/spec/ruby/core/symbol/casecmp_spec.rb b/spec/ruby/core/symbol/casecmp_spec.rb index 232399b664..b485101d63 100644 --- a/spec/ruby/core/symbol/casecmp_spec.rb +++ b/spec/ruby/core/symbol/casecmp_spec.rb @@ -73,74 +73,72 @@ describe "Symbol#casecmp" do end end -ruby_version_is "2.4" do - describe 'Symbol#casecmp?' do - it "compares symbols without regard to case" do - :abcdef.casecmp?(:abcde).should == false - :aBcDeF.casecmp?(:abcdef).should == true - :abcdef.casecmp?(:abcdefg).should == false - :abcdef.casecmp?(:ABCDEF).should == true - end - - it "doesn't consider non-ascii characters equal that aren't" do - # -- Latin-1 -- - upper_a_tilde = "\xC3".b.to_sym - upper_a_umlaut = "\xC4".b.to_sym - lower_a_tilde = "\xE3".b.to_sym - lower_a_umlaut = "\xE4".b.to_sym - - lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true - lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true - upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true - upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true - - # -- UTF-8 -- - upper_a_tilde = :"Ã" - lower_a_tilde = :"ã" - upper_a_umlaut = :"Ä" - lower_a_umlaut = :"ä" - - lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true - lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true - upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true - upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true - end - - it "doesn't do case mapping for non-ascii and non-unicode characters" do - # -- Latin-1 -- - upper_a_tilde = "\xC3".b.to_sym - upper_a_umlaut = "\xC4".b.to_sym - lower_a_tilde = "\xE3".b.to_sym - lower_a_umlaut = "\xE4".b.to_sym - - upper_a_tilde.casecmp?(lower_a_tilde).should == false - upper_a_umlaut.casecmp?(lower_a_umlaut).should == false - lower_a_tilde.casecmp?(upper_a_tilde).should == false - lower_a_umlaut.casecmp?(upper_a_umlaut).should == false - end - - it 'does case mapping for unicode characters' do - # -- UTF-8 -- - upper_a_tilde = :"Ã" - lower_a_tilde = :"ã" - upper_a_umlaut = :"Ä" - lower_a_umlaut = :"ä" - - upper_a_tilde.casecmp?(lower_a_tilde).should == true - upper_a_umlaut.casecmp?(lower_a_umlaut).should == true - lower_a_tilde.casecmp?(upper_a_tilde).should == true - lower_a_umlaut.casecmp?(upper_a_umlaut).should == true - end - - it 'returns nil when comparing characters with different encodings' do - # -- Latin-1 -- - upper_a_tilde = "\xC3".b.to_sym - - # -- UTF-8 -- - lower_a_tilde = :"ã" - - upper_a_tilde.casecmp?(lower_a_tilde).should == nil - lower_a_tilde.casecmp?(upper_a_tilde).should == nil - end +describe 'Symbol#casecmp?' do + it "compares symbols without regard to case" do + :abcdef.casecmp?(:abcde).should == false + :aBcDeF.casecmp?(:abcdef).should == true + :abcdef.casecmp?(:abcdefg).should == false + :abcdef.casecmp?(:ABCDEF).should == true + end + + it "doesn't consider non-ascii characters equal that aren't" do + # -- Latin-1 -- + upper_a_tilde = "\xC3".b.to_sym + upper_a_umlaut = "\xC4".b.to_sym + lower_a_tilde = "\xE3".b.to_sym + lower_a_umlaut = "\xE4".b.to_sym + + lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true + lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true + upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true + upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true + + # -- UTF-8 -- + upper_a_tilde = :"Ã" + lower_a_tilde = :"ã" + upper_a_umlaut = :"Ä" + lower_a_umlaut = :"ä" + + lower_a_tilde.casecmp?(lower_a_umlaut).should_not == true + lower_a_umlaut.casecmp?(lower_a_tilde).should_not == true + upper_a_tilde.casecmp?(upper_a_umlaut).should_not == true + upper_a_umlaut.casecmp?(upper_a_tilde).should_not == true + end + + it "doesn't do case mapping for non-ascii and non-unicode characters" do + # -- Latin-1 -- + upper_a_tilde = "\xC3".b.to_sym + upper_a_umlaut = "\xC4".b.to_sym + lower_a_tilde = "\xE3".b.to_sym + lower_a_umlaut = "\xE4".b.to_sym + + upper_a_tilde.casecmp?(lower_a_tilde).should == false + upper_a_umlaut.casecmp?(lower_a_umlaut).should == false + lower_a_tilde.casecmp?(upper_a_tilde).should == false + lower_a_umlaut.casecmp?(upper_a_umlaut).should == false + end + + it 'does case mapping for unicode characters' do + # -- UTF-8 -- + upper_a_tilde = :"Ã" + lower_a_tilde = :"ã" + upper_a_umlaut = :"Ä" + lower_a_umlaut = :"ä" + + upper_a_tilde.casecmp?(lower_a_tilde).should == true + upper_a_umlaut.casecmp?(lower_a_umlaut).should == true + lower_a_tilde.casecmp?(upper_a_tilde).should == true + lower_a_umlaut.casecmp?(upper_a_umlaut).should == true + end + + it 'returns nil when comparing characters with different encodings' do + # -- Latin-1 -- + upper_a_tilde = "\xC3".b.to_sym + + # -- UTF-8 -- + lower_a_tilde = :"ã" + + upper_a_tilde.casecmp?(lower_a_tilde).should == nil + lower_a_tilde.casecmp?(upper_a_tilde).should == nil end end diff --git a/spec/ruby/core/symbol/downcase_spec.rb b/spec/ruby/core/symbol/downcase_spec.rb index eb81c90d05..7e94c669cc 100644 --- a/spec/ruby/core/symbol/downcase_spec.rb +++ b/spec/ruby/core/symbol/downcase_spec.rb @@ -14,17 +14,9 @@ describe "Symbol#downcase" do "\u{E0}Bc".to_sym.downcase.should == :"àbc" end - ruby_version_is ''...'2.4' do - it "leaves uppercase Unicode characters as they were" do - "\u{DE}Bc".to_sym.downcase.should == :"Þbc" - end - end - - ruby_version_is '2.4' do - it "uncapitalizes all Unicode characters" do - "ÄÖÜ".to_sym.downcase.should == :"äöü" - "AOU".to_sym.downcase.should == :"aou" - end + it "uncapitalizes all Unicode characters" do + "ÄÖÜ".to_sym.downcase.should == :"äöü" + "AOU".to_sym.downcase.should == :"aou" end it "leaves non-alphabetic ASCII characters as they were" do diff --git a/spec/ruby/core/symbol/dup_spec.rb b/spec/ruby/core/symbol/dup_spec.rb index 202720e8f5..8b35917c27 100644 --- a/spec/ruby/core/symbol/dup_spec.rb +++ b/spec/ruby/core/symbol/dup_spec.rb @@ -1,9 +1,7 @@ require_relative '../../spec_helper' -ruby_version_is '2.4' do - describe "Symbol#dup" do - it "returns self" do - :a_symbol.dup.should equal(:a_symbol) - end +describe "Symbol#dup" do + it "returns self" do + :a_symbol.dup.should equal(:a_symbol) end end diff --git a/spec/ruby/core/symbol/match_spec.rb b/spec/ruby/core/symbol/match_spec.rb index c26d0569ed..d37155537b 100644 --- a/spec/ruby/core/symbol/match_spec.rb +++ b/spec/ruby/core/symbol/match_spec.rb @@ -19,52 +19,42 @@ describe "Symbol#=~" do it_behaves_like :symbol_match, :=~ end -ruby_version_is ""..."2.4" do - describe "Symbol#match" do - it_behaves_like :symbol_match, :match +describe "Symbol#match" do + it "returns the MatchData" do + result = :abc.match(/b/) + result.should be_kind_of(MatchData) + result[0].should == 'b' end -end - -ruby_version_is "2.4" do - describe "Symbol#match" do - it "returns the MatchData" do - result = :abc.match(/b/) - result.should be_kind_of(MatchData) - result[0].should == 'b' - end - it "returns nil if there is no match" do - :a.match(/b/).should be_nil - end + it "returns nil if there is no match" do + :a.match(/b/).should be_nil + end - it "sets the last match pseudo-variables" do - :a.match(/(.)/)[0].should == 'a' - $1.should == "a" - end + it "sets the last match pseudo-variables" do + :a.match(/(.)/)[0].should == 'a' + $1.should == "a" end end -ruby_version_is "2.4" do - describe "Symbol#match?" do - before :each do - # Resetting Regexp.last_match - /DONTMATCH/.match '' - end +describe "Symbol#match?" do + before :each do + # Resetting Regexp.last_match + /DONTMATCH/.match '' + end - context "when matches the given regex" do - it "returns true but does not set Regexp.last_match" do - :string.match?(/string/i).should be_true - Regexp.last_match.should be_nil - end + context "when matches the given regex" do + it "returns true but does not set Regexp.last_match" do + :string.match?(/string/i).should be_true + Regexp.last_match.should be_nil end + end - it "returns false when does not match the given regex" do - :string.match?(/STRING/).should be_false - end + it "returns false when does not match the given regex" do + :string.match?(/STRING/).should be_false + end - it "takes matching position as the 2nd argument" do - :string.match?(/str/i, 0).should be_true - :string.match?(/str/i, 1).should be_false - end + it "takes matching position as the 2nd argument" do + :string.match?(/str/i, 0).should be_true + :string.match?(/str/i, 1).should be_false end end diff --git a/spec/ruby/core/symbol/swapcase_spec.rb b/spec/ruby/core/symbol/swapcase_spec.rb index 9aec87a6d2..24709cac30 100644 --- a/spec/ruby/core/symbol/swapcase_spec.rb +++ b/spec/ruby/core/symbol/swapcase_spec.rb @@ -18,21 +18,9 @@ describe "Symbol#swapcase" do :mIxEd.swapcase.should == :MiXeD end - ruby_version_is ''...'2.4' do - it "leaves uppercase Unicode characters as they were" do - "\u{00DE}Bc".to_sym.swapcase.should == :"ÞbC" - end - - it "leaves lowercase Unicode characters as they were" do - "\u{00DF}Bc".to_sym.swapcase.should == :"ßbC" - end - end - - ruby_version_is '2.4' do - it "swaps the case for Unicode characters" do - "äÖü".to_sym.swapcase.should == :"ÄöÜ" - "aOu".to_sym.swapcase.should == :"AoU" - end + it "swaps the case for Unicode characters" do + "äÖü".to_sym.swapcase.should == :"ÄöÜ" + "aOu".to_sym.swapcase.should == :"AoU" end it "leaves non-alphabetic ASCII characters as they were" do diff --git a/spec/ruby/core/symbol/upcase_spec.rb b/spec/ruby/core/symbol/upcase_spec.rb index 6183f3b754..f704bdcbf3 100644 --- a/spec/ruby/core/symbol/upcase_spec.rb +++ b/spec/ruby/core/symbol/upcase_spec.rb @@ -10,17 +10,9 @@ describe "Symbol#upcase" do :lOwEr.upcase.should == :LOWER end - ruby_version_is ''...'2.4' do - it "leaves lowercase Unicode characters as they were" do - "\u{E0}Bc".to_sym.upcase.should == :"àBC" - end - end - - ruby_version_is '2.4' do - it "capitalizes all Unicode characters" do - "äöü".to_sym.upcase.should == :"ÄÖÜ" - "aou".to_sym.upcase.should == :"AOU" - end + it "capitalizes all Unicode characters" do + "äöü".to_sym.upcase.should == :"ÄÖÜ" + "aou".to_sym.upcase.should == :"AOU" end it "leaves non-alphabetic ASCII characters as they were" do |