summaryrefslogtreecommitdiff
path: root/spec/ruby/core/regexp/shared/quote.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/regexp/shared/quote.rb')
-rw-r--r--spec/ruby/core/regexp/shared/quote.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/spec/ruby/core/regexp/shared/quote.rb b/spec/ruby/core/regexp/shared/quote.rb
index 33bdfd9979..9533102766 100644
--- a/spec/ruby/core/regexp/shared/quote.rb
+++ b/spec/ruby/core/regexp/shared/quote.rb
@@ -17,6 +17,11 @@ describe :regexp_quote, shared: true do
Regexp.send(@method, str).should == '\+\[\]\('
end
+ it "works for broken strings" do
+ Regexp.send(@method, "a.\x85b.".force_encoding("US-ASCII")).should =="a\\.\x85b\\.".force_encoding("US-ASCII")
+ Regexp.send(@method, "a.\x80".force_encoding("UTF-8")).should == "a\\.\x80".force_encoding("UTF-8")
+ end
+
it "sets the encoding of the result to US-ASCII if there are only US-ASCII characters present in the input String" do
str = "abc".force_encoding("euc-jp")
Regexp.send(@method, str).encoding.should == Encoding::US_ASCII