diff options
Diffstat (limited to 'spec/ruby/core/string/swapcase_spec.rb')
-rw-r--r-- | spec/ruby/core/string/swapcase_spec.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb index 417f6c6d8d..7f4c68366d 100644 --- a/spec/ruby/core/string/swapcase_spec.rb +++ b/spec/ruby/core/string/swapcase_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -9,6 +10,10 @@ describe "String#swapcase" do "+++---111222???".swapcase.should == "+++---111222???" end + it "returns a String in the same encoding as self" do + "Hello".encode("US-ASCII").swapcase.encoding.should == Encoding::US_ASCII + end + describe "full Unicode case mapping" do it "works for all of Unicode with no option" do "äÖü".swapcase.should == "ÄöÜ" @@ -28,6 +33,10 @@ describe "String#swapcase" do it "does not swapcase non-ASCII characters" do "aßet".swapcase(:ascii).should == "AßET" end + + it "works with substrings" do + "prefix aTé"[-3..-1].swapcase(:ascii).should == "Até" + end end describe "full Unicode case mapping adapted for Turkic languages" do @@ -66,18 +75,9 @@ describe "String#swapcase" do -> { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError) end - ruby_version_is ''...'3.0' do - 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) - end - end - - ruby_version_is '3.0' do - it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("").swapcase.should be_an_instance_of(String) - StringSpecs::MyString.new("hello").swapcase.should be_an_instance_of(String) - end + it "returns String instances when called on a subclass" do + StringSpecs::MyString.new("").swapcase.should be_an_instance_of(String) + StringSpecs::MyString.new("hello").swapcase.should be_an_instance_of(String) end end |