summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-04-27 18:53:23 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-04-27 18:53:23 +0200
commita1b4816759418ca8fe510e8739622fc5d77ab0f0 (patch)
tree9d4fb6091d0086817f5bde46bf1150e9130d34fd /spec/ruby/core/string
parent00c33d9c232ed1a79eda17acd7231ac93caa162b (diff)
Update to ruby/spec@15c9619
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r--spec/ruby/core/string/capitalize_spec.rb212
-rw-r--r--spec/ruby/core/string/casecmp_spec.rb126
-rw-r--r--spec/ruby/core/string/concat_spec.rb30
-rw-r--r--spec/ruby/core/string/downcase_spec.rb214
-rw-r--r--spec/ruby/core/string/dump_spec.rb105
-rw-r--r--spec/ruby/core/string/lines_spec.rb10
-rw-r--r--spec/ruby/core/string/match_spec.rb34
-rw-r--r--spec/ruby/core/string/new_spec.rb8
-rw-r--r--spec/ruby/core/string/prepend_spec.rb30
-rw-r--r--spec/ruby/core/string/shared/each_line.rb48
-rw-r--r--spec/ruby/core/string/split_spec.rb60
-rw-r--r--spec/ruby/core/string/swapcase_spec.rb196
-rw-r--r--spec/ruby/core/string/to_f_spec.rb1
-rw-r--r--spec/ruby/core/string/unpack1_spec.rb14
-rw-r--r--spec/ruby/core/string/upcase_spec.rb200
15 files changed, 583 insertions, 705 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
diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb
index 87be999964..35afcc0152 100644
--- a/spec/ruby/core/string/casecmp_spec.rb
+++ b/spec/ruby/core/string/casecmp_spec.rb
@@ -101,10 +101,8 @@ describe "String#casecmp independent of case" 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
+ it "does not case fold" do
+ "ß".casecmp("ss").should == 1
end
end
@@ -129,88 +127,84 @@ describe "String#casecmp independent of case" do
end
end
-ruby_version_is "2.4" do
- describe 'String#casecmp? independent of case' do
- it 'returns true when equal to other' do
- 'abc'.casecmp?('abc').should == true
- 'abc'.casecmp?('ABC').should == true
- end
+describe 'String#casecmp? independent of case' do
+ it 'returns true when equal to other' do
+ 'abc'.casecmp?('abc').should == true
+ 'abc'.casecmp?('ABC').should == true
+ end
- it 'returns false when not equal to other' do
- 'abc'.casecmp?('DEF').should == false
- 'abc'.casecmp?('def').should == false
- end
+ it 'returns false when not equal to other' do
+ 'abc'.casecmp?('DEF').should == false
+ 'abc'.casecmp?('def').should == false
+ end
+
+ it "tries to convert other to string using to_str" do
+ other = mock('x')
+ other.should_receive(:to_str).and_return("abc")
- it "tries to convert other to string using to_str" do
- other = mock('x')
- other.should_receive(:to_str).and_return("abc")
+ "abc".casecmp?(other).should == true
+ end
+
+ it "returns nil if incompatible encodings" do
+ "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should be_nil
+ end
- "abc".casecmp?(other).should == true
+ describe 'for UNICODE characters' do
+ it 'returns true when downcase(:fold) on unicode' do
+ 'äöü'.casecmp?('ÄÖÜ').should == true
end
+ end
- it "returns nil if incompatible encodings" do
- "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should be_nil
+ describe "when comparing a subclass instance" do
+ it 'returns true when equal to other' do
+ a = StringSpecs::MyString.new "a"
+ 'a'.casecmp?(a).should == true
+ 'A'.casecmp?(a).should == true
end
- describe 'for UNICODE characters' do
- it 'returns true when downcase(:fold) on unicode' do
- 'äöü'.casecmp?('ÄÖÜ').should == true
- end
+ it 'returns false when not equal to other' do
+ b = StringSpecs::MyString.new "a"
+ 'b'.casecmp?(b).should == false
+ 'B'.casecmp?(b).should == false
end
+ end
- describe "when comparing a subclass instance" do
- it 'returns true when equal to other' do
- a = StringSpecs::MyString.new "a"
- 'a'.casecmp?(a).should == true
- 'A'.casecmp?(a).should == true
+ describe "in UTF-8 mode" do
+ describe "for non-ASCII characters" do
+ before :each do
+ @upper_a_tilde = "Ã"
+ @lower_a_tilde = "ã"
+ @upper_a_umlaut = "Ä"
+ @lower_a_umlaut = "ä"
end
- it 'returns false when not equal to other' do
- b = StringSpecs::MyString.new "a"
- 'b'.casecmp?(b).should == false
- 'B'.casecmp?(b).should == false
+ it "returns true when they are the same with normalized case" do
+ @upper_a_tilde.casecmp?(@lower_a_tilde).should == true
end
- end
-
- describe "in UTF-8 mode" do
- describe "for non-ASCII characters" do
- before :each do
- @upper_a_tilde = "Ã"
- @lower_a_tilde = "ã"
- @upper_a_umlaut = "Ä"
- @lower_a_umlaut = "ä"
- end
-
- it "returns true when they are the same with normalized case" do
- @upper_a_tilde.casecmp?(@lower_a_tilde).should == true
- end
-
- it "returns false when they are unrelated" do
- @upper_a_tilde.casecmp?(@upper_a_umlaut).should == false
- end
- it "returns true when they have the same bytes" do
- @upper_a_tilde.casecmp?(@upper_a_tilde).should == true
- end
+ it "returns false when they are unrelated" do
+ @upper_a_tilde.casecmp?(@upper_a_umlaut).should == false
end
- end
- ruby_version_is "2.4" do
- it "case folds" do
- "ß".casecmp?("ss").should be_true
+ it "returns true when they have the same bytes" do
+ @upper_a_tilde.casecmp?(@upper_a_tilde).should == true
end
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)
- end
+ it "case folds" do
+ "ß".casecmp?("ss").should be_true
+ 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)
end
+ end
- ruby_version_is "2.5" do
- it "returns nil if other can't be converted to a string" do
- "abc".casecmp?(mock('abc')).should be_nil
- end
+ ruby_version_is "2.5" do
+ it "returns nil if other can't be converted to a string" do
+ "abc".casecmp?(mock('abc')).should be_nil
end
end
end
diff --git a/spec/ruby/core/string/concat_spec.rb b/spec/ruby/core/string/concat_spec.rb
index 27917d6c85..5f6daadad7 100644
--- a/spec/ruby/core/string/concat_spec.rb
+++ b/spec/ruby/core/string/concat_spec.rb
@@ -6,23 +6,21 @@ describe "String#concat" do
it_behaves_like :string_concat, :concat
it_behaves_like :string_concat_encoding, :concat
- ruby_version_is "2.4" do
- it "takes multiple arguments" do
- str = "hello "
- str.concat "wo", "", "rld"
- str.should == "hello world"
- end
+ it "takes multiple arguments" do
+ str = "hello "
+ str.concat "wo", "", "rld"
+ str.should == "hello world"
+ end
- it "concatenates the initial value when given arguments contain 2 self" do
- str = "hello"
- str.concat str, str
- str.should == "hellohellohello"
- end
+ it "concatenates the initial value when given arguments contain 2 self" do
+ str = "hello"
+ str.concat str, str
+ str.should == "hellohellohello"
+ end
- it "returns self when given no arguments" do
- str = "hello"
- str.concat.should equal(str)
- str.should == "hello"
- end
+ it "returns self when given no arguments" do
+ str = "hello"
+ str.concat.should equal(str)
+ str.should == "hello"
end
end
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
diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb
index e67367b5b0..aa91114893 100644
--- a/spec/ruby/core/string/dump_spec.rb
+++ b/spec/ruby/core/string/dump_spec.rb
@@ -352,78 +352,39 @@ describe "String#dump" do
].should be_computed_by(:dump)
end
- ruby_version_is ''...'2.4' do
- it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
- [ [0200.chr('utf-8'), '"\u{80}"'],
- [0201.chr('utf-8'), '"\u{81}"'],
- [0202.chr('utf-8'), '"\u{82}"'],
- [0203.chr('utf-8'), '"\u{83}"'],
- [0204.chr('utf-8'), '"\u{84}"'],
- [0206.chr('utf-8'), '"\u{86}"'],
- [0207.chr('utf-8'), '"\u{87}"'],
- [0210.chr('utf-8'), '"\u{88}"'],
- [0211.chr('utf-8'), '"\u{89}"'],
- [0212.chr('utf-8'), '"\u{8a}"'],
- [0213.chr('utf-8'), '"\u{8b}"'],
- [0214.chr('utf-8'), '"\u{8c}"'],
- [0215.chr('utf-8'), '"\u{8d}"'],
- [0216.chr('utf-8'), '"\u{8e}"'],
- [0217.chr('utf-8'), '"\u{8f}"'],
- [0220.chr('utf-8'), '"\u{90}"'],
- [0221.chr('utf-8'), '"\u{91}"'],
- [0222.chr('utf-8'), '"\u{92}"'],
- [0223.chr('utf-8'), '"\u{93}"'],
- [0224.chr('utf-8'), '"\u{94}"'],
- [0225.chr('utf-8'), '"\u{95}"'],
- [0226.chr('utf-8'), '"\u{96}"'],
- [0227.chr('utf-8'), '"\u{97}"'],
- [0230.chr('utf-8'), '"\u{98}"'],
- [0231.chr('utf-8'), '"\u{99}"'],
- [0232.chr('utf-8'), '"\u{9a}"'],
- [0233.chr('utf-8'), '"\u{9b}"'],
- [0234.chr('utf-8'), '"\u{9c}"'],
- [0235.chr('utf-8'), '"\u{9d}"'],
- [0236.chr('utf-8'), '"\u{9e}"'],
- [0237.chr('utf-8'), '"\u{9f}"'],
- ].should be_computed_by(:dump)
- end
- end
-
- ruby_version_is '2.4' do
- it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with upper-case hex digits" do
- [ [0200.chr('utf-8'), '"\u0080"'],
- [0201.chr('utf-8'), '"\u0081"'],
- [0202.chr('utf-8'), '"\u0082"'],
- [0203.chr('utf-8'), '"\u0083"'],
- [0204.chr('utf-8'), '"\u0084"'],
- [0206.chr('utf-8'), '"\u0086"'],
- [0207.chr('utf-8'), '"\u0087"'],
- [0210.chr('utf-8'), '"\u0088"'],
- [0211.chr('utf-8'), '"\u0089"'],
- [0212.chr('utf-8'), '"\u008A"'],
- [0213.chr('utf-8'), '"\u008B"'],
- [0214.chr('utf-8'), '"\u008C"'],
- [0215.chr('utf-8'), '"\u008D"'],
- [0216.chr('utf-8'), '"\u008E"'],
- [0217.chr('utf-8'), '"\u008F"'],
- [0220.chr('utf-8'), '"\u0090"'],
- [0221.chr('utf-8'), '"\u0091"'],
- [0222.chr('utf-8'), '"\u0092"'],
- [0223.chr('utf-8'), '"\u0093"'],
- [0224.chr('utf-8'), '"\u0094"'],
- [0225.chr('utf-8'), '"\u0095"'],
- [0226.chr('utf-8'), '"\u0096"'],
- [0227.chr('utf-8'), '"\u0097"'],
- [0230.chr('utf-8'), '"\u0098"'],
- [0231.chr('utf-8'), '"\u0099"'],
- [0232.chr('utf-8'), '"\u009A"'],
- [0233.chr('utf-8'), '"\u009B"'],
- [0234.chr('utf-8'), '"\u009C"'],
- [0235.chr('utf-8'), '"\u009D"'],
- [0236.chr('utf-8'), '"\u009E"'],
- [0237.chr('utf-8'), '"\u009F"'],
- ].should be_computed_by(:dump)
- end
+ it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with upper-case hex digits" do
+ [ [0200.chr('utf-8'), '"\u0080"'],
+ [0201.chr('utf-8'), '"\u0081"'],
+ [0202.chr('utf-8'), '"\u0082"'],
+ [0203.chr('utf-8'), '"\u0083"'],
+ [0204.chr('utf-8'), '"\u0084"'],
+ [0206.chr('utf-8'), '"\u0086"'],
+ [0207.chr('utf-8'), '"\u0087"'],
+ [0210.chr('utf-8'), '"\u0088"'],
+ [0211.chr('utf-8'), '"\u0089"'],
+ [0212.chr('utf-8'), '"\u008A"'],
+ [0213.chr('utf-8'), '"\u008B"'],
+ [0214.chr('utf-8'), '"\u008C"'],
+ [0215.chr('utf-8'), '"\u008D"'],
+ [0216.chr('utf-8'), '"\u008E"'],
+ [0217.chr('utf-8'), '"\u008F"'],
+ [0220.chr('utf-8'), '"\u0090"'],
+ [0221.chr('utf-8'), '"\u0091"'],
+ [0222.chr('utf-8'), '"\u0092"'],
+ [0223.chr('utf-8'), '"\u0093"'],
+ [0224.chr('utf-8'), '"\u0094"'],
+ [0225.chr('utf-8'), '"\u0095"'],
+ [0226.chr('utf-8'), '"\u0096"'],
+ [0227.chr('utf-8'), '"\u0097"'],
+ [0230.chr('utf-8'), '"\u0098"'],
+ [0231.chr('utf-8'), '"\u0099"'],
+ [0232.chr('utf-8'), '"\u009A"'],
+ [0233.chr('utf-8'), '"\u009B"'],
+ [0234.chr('utf-8'), '"\u009C"'],
+ [0235.chr('utf-8'), '"\u009D"'],
+ [0236.chr('utf-8'), '"\u009E"'],
+ [0237.chr('utf-8'), '"\u009F"'],
+ ].should be_computed_by(:dump)
end
it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do
diff --git a/spec/ruby/core/string/lines_spec.rb b/spec/ruby/core/string/lines_spec.rb
index 1c13936c30..ad4b119074 100644
--- a/spec/ruby/core/string/lines_spec.rb
+++ b/spec/ruby/core/string/lines_spec.rb
@@ -11,12 +11,10 @@ describe "String#lines" do
ary.should == ["hello ", "world"]
end
- ruby_version_is '2.4' do
- context "when `chomp` keyword argument is passed" do
- it "removes new line characters" do
- "hello \nworld\n".lines(chomp: true).should == ["hello ", "world"]
- "hello \r\nworld\r\n".lines(chomp: true).should == ["hello ", "world"]
- end
+ context "when `chomp` keyword argument is passed" do
+ it "removes new line characters" do
+ "hello \nworld\n".lines(chomp: true).should == ["hello ", "world"]
+ "hello \r\nworld\r\n".lines(chomp: true).should == ["hello ", "world"]
end
end
end
diff --git a/spec/ruby/core/string/match_spec.rb b/spec/ruby/core/string/match_spec.rb
index 7f3d9ebae5..67e015f23d 100644
--- a/spec/ruby/core/string/match_spec.rb
+++ b/spec/ruby/core/string/match_spec.rb
@@ -149,27 +149,25 @@ describe "String#match" do
end
end
-ruby_version_is "2.4" do
- describe "String#match?" do
- before :each do
- # Resetting Regexp.last_match
- /DONTMATCH/.match ''
- end
+describe "String#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/string/new_spec.rb b/spec/ruby/core/string/new_spec.rb
index a65c6da2d1..f65daf2dd2 100644
--- a/spec/ruby/core/string/new_spec.rb
+++ b/spec/ruby/core/string/new_spec.rb
@@ -13,11 +13,9 @@ describe "String.new" do
str.encoding.should == Encoding::EUC_JP
end
- ruby_version_is "2.4" do
- it "accepts a capacity argument" do
- String.new("", capacity: 100_000).should == ""
- String.new("abc", capacity: 100_000).should == "abc"
- end
+ it "accepts a capacity argument" do
+ String.new("", capacity: 100_000).should == ""
+ String.new("abc", capacity: 100_000).should == "abc"
end
it "returns a fully-formed String" do
diff --git a/spec/ruby/core/string/prepend_spec.rb b/spec/ruby/core/string/prepend_spec.rb
index cbe83524b8..e2c29de836 100644
--- a/spec/ruby/core/string/prepend_spec.rb
+++ b/spec/ruby/core/string/prepend_spec.rb
@@ -42,23 +42,21 @@ describe "String#prepend" do
x.prepend("y".taint).tainted?.should be_true
end
- ruby_version_is "2.4" do
- it "takes multiple arguments" do
- str = " world"
- str.prepend "he", "", "llo"
- str.should == "hello world"
- end
+ it "takes multiple arguments" do
+ str = " world"
+ str.prepend "he", "", "llo"
+ str.should == "hello world"
+ end
- it "prepends the initial value when given arguments contain 2 self" do
- str = "hello"
- str.prepend str, str
- str.should == "hellohellohello"
- end
+ it "prepends the initial value when given arguments contain 2 self" do
+ str = "hello"
+ str.prepend str, str
+ str.should == "hellohellohello"
+ end
- it "returns self when given no arguments" do
- str = "hello"
- str.prepend.should equal(str)
- str.should == "hello"
- end
+ it "returns self when given no arguments" do
+ str = "hello"
+ str.prepend.should equal(str)
+ str.should == "hello"
end
end
diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb
index 066b0c1040..86c966e50b 100644
--- a/spec/ruby/core/string/shared/each_line.rb
+++ b/spec/ruby/core/string/shared/each_line.rb
@@ -145,34 +145,32 @@ describe :string_each_line, shared: true do
lambda { "hello world".send(@method, :o).to_a }.should raise_error(TypeError)
end
- ruby_version_is '2.4' do
- context "when `chomp` keyword argument is passed" do
- it "removes new line characters when separator is not specified" do
- a = []
- "hello \nworld\n".send(@method, chomp: true) { |s| a << s }
- a.should == ["hello ", "world"]
-
- a = []
- "hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
- a.should == ["hello ", "world"]
- end
+ context "when `chomp` keyword argument is passed" do
+ it "removes new line characters when separator is not specified" do
+ a = []
+ "hello \nworld\n".send(@method, chomp: true) { |s| a << s }
+ a.should == ["hello ", "world"]
- it "removes only specified separator" do
- a = []
- "hello world".send(@method, ' ', chomp: true) { |s| a << s }
- a.should == ["hello", "world"]
- end
+ a = []
+ "hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
+ a.should == ["hello ", "world"]
+ end
- # https://bugs.ruby-lang.org/issues/14257
- it "ignores new line characters when separator is specified" do
- a = []
- "hello\n world\n".send(@method, ' ', chomp: true) { |s| a << s }
- a.should == ["hello\n", "world\n"]
+ it "removes only specified separator" do
+ a = []
+ "hello world".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello", "world"]
+ end
- a = []
- "hello\r\n world\r\n".send(@method, ' ', chomp: true) { |s| a << s }
- a.should == ["hello\r\n", "world\r\n"]
- end
+ # https://bugs.ruby-lang.org/issues/14257
+ it "ignores new line characters when separator is specified" do
+ a = []
+ "hello\n world\n".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello\n", "world\n"]
+
+ a = []
+ "hello\r\n world\r\n".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello\r\n", "world\r\n"]
end
end
end
diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb
index 7d5a591790..82f261b8df 100644
--- a/spec/ruby/core/string/split_spec.rb
+++ b/spec/ruby/core/string/split_spec.rb
@@ -65,28 +65,26 @@ describe "String#split with String" do
end
it "defaults to $; when string isn't given or nil" do
- begin
- verbose = $VERBOSE
- $VERBOSE = nil
+ suppress_warning do
old_fs = $;
+ begin
+ [",", ":", "", "XY", nil].each do |fs|
+ $; = fs
- [",", ":", "", "XY", nil].each do |fs|
- $; = fs
+ ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
+ expected = str.split(fs || " ")
- ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
- expected = str.split(fs || " ")
+ str.split(nil).should == expected
+ str.split.should == expected
- str.split(nil).should == expected
- str.split.should == expected
-
- str.split(nil, -1).should == str.split(fs || " ", -1)
- str.split(nil, 0).should == str.split(fs || " ", 0)
- str.split(nil, 2).should == str.split(fs || " ", 2)
+ str.split(nil, -1).should == str.split(fs || " ", -1)
+ str.split(nil, 0).should == str.split(fs || " ", 0)
+ str.split(nil, 2).should == str.split(fs || " ", 2)
+ end
end
+ ensure
+ $; = old_fs
end
- ensure
- $; = old_fs
- $VERBOSE = verbose
end
end
@@ -241,28 +239,26 @@ describe "String#split with Regexp" do
end
it "defaults to $; when regexp isn't given or nil" do
- begin
- verbose = $VERBOSE
- $VERBOSE = nil
+ suppress_warning do
old_fs = $;
+ begin
+ [/,/, /:/, //, /XY/, /./].each do |fs|
+ $; = fs
- [/,/, /:/, //, /XY/, /./].each do |fs|
- $; = fs
+ ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
+ expected = str.split(fs)
- ["x,y,z,,,", "1:2:", "aXYbXYcXY", ""].each do |str|
- expected = str.split(fs)
+ str.split(nil).should == expected
+ str.split.should == expected
- str.split(nil).should == expected
- str.split.should == expected
-
- str.split(nil, -1).should == str.split(fs, -1)
- str.split(nil, 0).should == str.split(fs, 0)
- str.split(nil, 2).should == str.split(fs, 2)
+ str.split(nil, -1).should == str.split(fs, -1)
+ str.split(nil, 0).should == str.split(fs, 0)
+ str.split(nil, 2).should == str.split(fs, 2)
+ end
end
+ ensure
+ $; = old_fs
end
- ensure
- $; = old_fs
- $VERBOSE = verbose
end
end
diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb
index bb89dee48f..c35751859e 100644
--- a/spec/ruby/core/string/swapcase_spec.rb
+++ b/spec/ruby/core/string/swapcase_spec.rb
@@ -14,73 +14,63 @@ describe "String#swapcase" do
"hello".taint.swapcase.tainted?.should == true
end
- ruby_version_is ''...'2.4' do
- it "is locale insensitive (only upcases a-z and only downcases A-Z)" do
- "ÄÖÜ".swapcase.should == "ÄÖÜ"
- "ärger".swapcase.should == "äRGER"
- "BÄR".swapcase.should == "bÄr"
+ describe "full Unicode case mapping" do
+ it "works for all of Unicode with no option" do
+ "äÖü".swapcase.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
- "äÖü".swapcase.should == "ÄöÜ"
- end
- it "updates string metadata" do
- swapcased = "Aßet".swapcase
+ it "updates string metadata" do
+ swapcased = "Aßet".swapcase
- swapcased.should == "aSSET"
- swapcased.size.should == 5
- swapcased.bytesize.should == 5
- swapcased.ascii_only?.should be_true
- end
+ swapcased.should == "aSSET"
+ swapcased.size.should == 5
+ swapcased.bytesize.should == 5
+ swapcased.ascii_only?.should be_true
end
+ end
- describe "ASCII-only case mapping" do
- it "does not swapcase non-ASCII characters" do
- "aßet".swapcase(:ascii).should == "AßET"
- end
+ describe "ASCII-only case mapping" do
+ it "does not swapcase non-ASCII characters" do
+ "aßet".swapcase(:ascii).should == "AßET"
end
+ end
- describe "full Unicode case mapping adapted for Turkic languages" do
- it "swaps case of ASCII characters according to Turkic semantics" do
- "aiS".swapcase(:turkic).should == "Aİs"
- end
-
- it "allows Lithuanian as an extra option" do
- "aiS".swapcase(:turkic, :lithuanian).should == "Aİs"
- end
-
- it "does not allow any other additional option" do
- lambda { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
+ describe "full Unicode case mapping adapted for Turkic languages" do
+ it "swaps case of ASCII characters according to Turkic semantics" do
+ "aiS".swapcase(:turkic).should == "Aİs"
end
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- "Iß".swapcase(:lithuanian).should == "iSS"
- end
+ it "allows Lithuanian as an extra option" do
+ "aiS".swapcase(:turkic, :lithuanian).should == "Aİs"
+ end
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- "iS".swapcase(:lithuanian, :turkic).should == "İs"
- end
+ it "does not allow any other additional option" do
+ lambda { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError)
+ end
+ end
- it "does not allow any other additional option" do
- lambda { "aiS".swapcase(: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ß".swapcase(:lithuanian).should == "iSS"
end
- it "does not allow the :fold option for upcasing" do
- lambda { "abc".swapcase(:fold) }.should raise_error(ArgumentError)
+ it "allows Turkic as an extra option (and applies Turkic semantics)" do
+ "iS".swapcase(:lithuanian, :turkic).should == "İs"
end
- it "does not allow invalid options" do
- lambda { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError)
+ it "does not allow any other additional option" do
+ lambda { "aiS".swapcase(:lithuanian, :ascii) }.should raise_error(ArgumentError)
end
end
+ it "does not allow the :fold option for upcasing" do
+ lambda { "abc".swapcase(:fold) }.should raise_error(ArgumentError)
+ end
+
+ it "does not allow invalid options" do
+ lambda { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError)
+ end
+
it "returns subclass instances when called on a subclass" do
StringSpecs::MyString.new("").swapcase.should be_an_instance_of(StringSpecs::MyString)
StringSpecs::MyString.new("hello").swapcase.should be_an_instance_of(StringSpecs::MyString)
@@ -94,78 +84,76 @@ describe "String#swapcase!" do
a.should == "CyBeR_pUnK11"
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.swapcase!
- a.should == "ÄöÜ"
- end
+ describe "full Unicode case mapping" do
+ it "modifies self in place for all of Unicode with no option" do
+ a = "äÖü"
+ a.swapcase!
+ a.should == "ÄöÜ"
+ end
- it "updates string metadata" do
- swapcased = "Aßet"
- swapcased.swapcase!
+ it "updates string metadata" do
+ swapcased = "Aßet"
+ swapcased.swapcase!
- swapcased.should == "aSSET"
- swapcased.size.should == 5
- swapcased.bytesize.should == 5
- swapcased.ascii_only?.should be_true
- end
+ swapcased.should == "aSSET"
+ swapcased.size.should == 5
+ swapcased.bytesize.should == 5
+ swapcased.ascii_only?.should be_true
end
+ end
- describe "modifies self in place for ASCII-only case mapping" do
- it "does not swapcase non-ASCII characters" do
- a = "aßet"
- a.swapcase!(:ascii)
- a.should == "AßET"
- end
+ describe "modifies self in place for ASCII-only case mapping" do
+ it "does not swapcase non-ASCII characters" do
+ a = "aßet"
+ a.swapcase!(:ascii)
+ a.should == "AßET"
end
+ end
- describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do
- it "swaps case of ASCII characters according to Turkic semantics" do
- a = "aiS"
- a.swapcase!(:turkic)
- a.should == "Aİs"
- end
-
- it "allows Lithuanian as an extra option" do
- a = "aiS"
- a.swapcase!(:turkic, :lithuanian)
- a.should == "Aİs"
- end
-
- it "does not allow any other additional option" do
- lambda { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
- end
+ describe "modifies self in place for full Unicode case mapping adapted for Turkic languages" do
+ it "swaps case of ASCII characters according to Turkic semantics" do
+ a = "aiS"
+ a.swapcase!(:turkic)
+ a.should == "Aİs"
end
- describe "full Unicode case mapping adapted for Lithuanian" do
- it "currently works the same as full Unicode case mapping" do
- a = "Iß"
- a.swapcase!(:lithuanian)
- a.should == "iSS"
- end
+ it "allows Lithuanian as an extra option" do
+ a = "aiS"
+ a.swapcase!(:turkic, :lithuanian)
+ a.should == "Aİs"
+ end
- it "allows Turkic as an extra option (and applies Turkic semantics)" do
- a = "iS"
- a.swapcase!(:lithuanian, :turkic)
- a.should == "İs"
- end
+ it "does not allow any other additional option" do
+ lambda { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
+ end
+ end
- it "does not allow any other additional option" do
- lambda { a = "aiS"; a.swapcase!(: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
+ a = "Iß"
+ a.swapcase!(:lithuanian)
+ a.should == "iSS"
end
- it "does not allow the :fold option for upcasing" do
- lambda { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError)
+ it "allows Turkic as an extra option (and applies Turkic semantics)" do
+ a = "iS"
+ a.swapcase!(:lithuanian, :turkic)
+ a.should == "İs"
end
- it "does not allow invalid options" do
- lambda { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError)
+ it "does not allow any other additional option" do
+ lambda { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
end
end
+ it "does not allow the :fold option for upcasing" do
+ lambda { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError)
+ end
+
+ it "does not allow invalid options" do
+ lambda { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError)
+ end
+
it "returns nil if no modifications were made" do
a = "+++---111222???"
a.swapcase!.should == nil
diff --git a/spec/ruby/core/string/to_f_spec.rb b/spec/ruby/core/string/to_f_spec.rb
index ca8536c30e..cf64ecfc5d 100644
--- a/spec/ruby/core/string/to_f_spec.rb
+++ b/spec/ruby/core/string/to_f_spec.rb
@@ -12,6 +12,7 @@ describe "String#to_f" do
".5".to_f.should == 0.5
".5e1".to_f.should == 5.0
+ "5.".to_f.should == 5.0
"5e".to_f.should == 5.0
"5E".to_f.should == 5.0
end
diff --git a/spec/ruby/core/string/unpack1_spec.rb b/spec/ruby/core/string/unpack1_spec.rb
index 5b2157d85a..5fe81733fb 100644
--- a/spec/ruby/core/string/unpack1_spec.rb
+++ b/spec/ruby/core/string/unpack1_spec.rb
@@ -1,12 +1,10 @@
require_relative '../../spec_helper'
-ruby_version_is "2.4" do
- describe "String#unpack1" do
- it "returns the first value of #unpack" do
- "ABCD".unpack1('x3C').should == "ABCD".unpack('x3C')[0]
- "\u{3042 3044 3046}".unpack1("U*").should == 0x3042
- "aG9nZWZ1Z2E=".unpack1("m").should == "hogefuga"
- "A".unpack1("B*").should == "01000001"
- end
+describe "String#unpack1" do
+ it "returns the first value of #unpack" do
+ "ABCD".unpack1('x3C').should == "ABCD".unpack('x3C')[0]
+ "\u{3042 3044 3046}".unpack1("U*").should == 0x3042
+ "aG9nZWZ1Z2E=".unpack1("m").should == "hogefuga"
+ "A".unpack1("B*").should == "01000001"
end
end
diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb
index 347f567be9..eb736ebfa1 100644
--- a/spec/ruby/core/string/upcase_spec.rb
+++ b/spec/ruby/core/string/upcase_spec.rb
@@ -8,79 +8,63 @@ describe "String#upcase" do
"hello".upcase.should == "HELLO"
end
- ruby_version_is ''...'2.4' do
- it "is locale insensitive (only replaces a-z)" do
- "äöü".upcase.should == "äöü"
+ describe "full Unicode case mapping" do
+ it "works for all of Unicode with no option" do
+ "äöü".upcase.should == "ÄÖÜ"
+ end
- str = Array.new(256) { |c| c.chr }.join
- expected = Array.new(256) do |i|
- c = i.chr
- c.between?("a", "z") ? c.upcase : c
- end.join
+ it "updates string metadata" do
+ upcased = "aßet".upcase
- str.upcase.should == expected
+ upcased.should == "ASSET"
+ upcased.size.should == 5
+ upcased.bytesize.should == 5
+ upcased.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
- "äöü".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
+ describe "ASCII-only case mapping" do
+ it "does not upcase non-ASCII characters" do
+ "aßet".upcase(:ascii).should == "AßET"
end
+ end
- describe "ASCII-only case mapping" do
- it "does not upcase non-ASCII characters" do
- "aßet".upcase(:ascii).should == "AßET"
- 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
- 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
+ it "allows Lithuanian as an extra option" do
+ "i".upcase(:turkic, :lithuanian).should == "İ"
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(:turkic, :ascii) }.should raise_error(ArgumentError)
+ end
+ end
- it "does not allow any other additional option" do
- lambda { "iß".upcase(: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ß".upcase(:lithuanian).should == "ISS"
end
- it "does not allow the :fold option for upcasing" do
- lambda { "abc".upcase(:fold) }.should raise_error(ArgumentError)
+ it "allows Turkic as an extra option (and applies Turkic semantics)" do
+ "iß".upcase(:lithuanian, :turkic).should == "İSS"
end
- it "does not allow invalid options" do
- lambda { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError)
+ 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
+
it "taints result when self is tainted" do
"".taint.upcase.tainted?.should == true
"X".taint.upcase.tainted?.should == true
@@ -99,78 +83,76 @@ describe "String#upcase!" 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.upcase!
- a.should == "ÄÖÜ"
- end
+ 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!
+ 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
+ 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
+ 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
+ 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
- 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 Lithuanian as an extra option" do
+ a = "i"
+ a.upcase!(:turkic, :lithuanian)
+ a.should == "İ"
+ 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!(:turkic, :ascii) }.should raise_error(ArgumentError)
+ end
+ end
- it "does not allow any other additional option" do
- lambda { a = "iß"; a.upcase!(: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.upcase!(:lithuanian)
+ a.should == "ISS"
end
- it "does not allow the :fold option for upcasing" do
- lambda { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError)
+ 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 invalid options" do
- lambda { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError)
+ 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
+
it "returns nil if no modifications were made" do
a = "HELLO"
a.upcase!.should == nil