1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-06-27 21:02:36 +02:00
parent c940397116
commit d80e44deec
157 changed files with 581 additions and 543 deletions

View file

@ -14,8 +14,8 @@ describe "Regexp#encoding" do
/ASCII/n.encoding.should == Encoding::US_ASCII
end
it "returns ASCII-8BIT if the 'n' modifier is supplied and non-US-ASCII characters are present" do
/\xc2\xa1/n.encoding.should == Encoding::ASCII_8BIT
it "returns BINARY if the 'n' modifier is supplied and non-US-ASCII characters are present" do
/\xc2\xa1/n.encoding.should == Encoding::BINARY
end
it "defaults to UTF-8 if \\u escapes appear" do

View file

@ -1,4 +1,4 @@
# -*- encoding: ascii-8bit -*-
# -*- encoding: binary -*-
describe :regexp_new, shared: true do
it "requires one argument and creates a new regular expression object" do
@ -135,10 +135,10 @@ describe :regexp_new_string, shared: true do
a = "(?:[\x8E\xA1-\xFE])"
str = "\A(?:#{a}|x*)\z"
Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::ASCII_8BIT
Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::ASCII_8BIT
Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::ASCII_8BIT
Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::ASCII_8BIT
Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::BINARY
Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::BINARY
Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::BINARY
Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::BINARY
end
describe "with escaped characters" do
@ -499,7 +499,7 @@ describe :regexp_new_regexp, shared: true do
end
it "sets the encoding to source String's encoding if the Regexp literal has the 'n' option and the source String is not ASCII only" do
Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::ASCII_8BIT
Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::BINARY
end
end
end

View file

@ -1,4 +1,4 @@
# -*- encoding: ascii-8bit -*-
# -*- encoding: binary -*-
describe :regexp_quote, shared: true do
it "escapes any characters with special meaning in a regular expression" do
@ -23,9 +23,9 @@ describe :regexp_quote, shared: true do
Regexp.send(@method, str).encoding.should == Encoding::UTF_8
end
it "sets the encoding of the result to ASCII-8BIT if any non-US-ASCII characters are present in an input String with invalid encoding" do
it "sets the encoding of the result to BINARY if any non-US-ASCII characters are present in an input String with invalid encoding" do
str = "\xff".force_encoding "us-ascii"
str.valid_encoding?.should be_false
Regexp.send(@method, "\xff").encoding.should == Encoding::ASCII_8BIT
Regexp.send(@method, "\xff").encoding.should == Encoding::BINARY
end
end