diff options
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r-- | spec/ruby/core/string/inspect_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/string/modulo_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/core/string/percent_spec.rb | 13 |
3 files changed, 18 insertions, 13 deletions
diff --git a/spec/ruby/core/string/inspect_spec.rb b/spec/ruby/core/string/inspect_spec.rb index 8ddbae132a..e63d89ead5 100644 --- a/spec/ruby/core/string/inspect_spec.rb +++ b/spec/ruby/core/string/inspect_spec.rb @@ -319,6 +319,10 @@ describe "String#inspect" do 0.chr.inspect.should == '"\\x00"' end + it "uses \\x notation for broken UTF-8 sequences" do + "\xF0\x9F".inspect.should == '"\\xF0\\x9F"' + end + describe "when default external is UTF-8" do before :each do @extenc, Encoding.default_external = Encoding.default_external, Encoding::UTF_8 diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb index a16112bf44..35ee0b16f5 100644 --- a/spec/ruby/core/string/modulo_spec.rb +++ b/spec/ruby/core/string/modulo_spec.rb @@ -1,8 +1,22 @@ require_relative '../../spec_helper' +require_relative '../kernel/shared/sprintf' +require_relative '../kernel/shared/sprintf_encoding' require_relative 'fixtures/classes' require_relative '../../shared/hash/key_error' describe "String#%" do + it_behaves_like :kernel_sprintf, -> format, *args { + format % args + } + + it_behaves_like :kernel_sprintf_encoding, -> format, *args { + format % args + } +end + +# TODO: these specs are mostly redundant with kernel/shared/sprintf.rb specs. +# These specs should be moved there and deduplicated. +describe "String#%" do context "when key is missing from passed-in hash" do it_behaves_like :key_error, -> obj, key { "%{#{key}}" % obj }, { a: 5 } end diff --git a/spec/ruby/core/string/percent_spec.rb b/spec/ruby/core/string/percent_spec.rb deleted file mode 100644 index e3460522b1..0000000000 --- a/spec/ruby/core/string/percent_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_relative '../../spec_helper' -require_relative '../kernel/shared/sprintf' -require_relative '../kernel/shared/sprintf_encoding' - -describe "String#%" do - it_behaves_like :kernel_sprintf, -> format, *args { - format % args - } - - it_behaves_like :kernel_sprintf_encoding, -> format, *args { - format % args - } -end |