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-07-27 12:40:09 +02:00
parent a06301b103
commit 5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions

View file

@ -6,10 +6,10 @@ describe "Regexp#initialize" do
end
it "raises a SecurityError on a Regexp literal" do
lambda { //.send(:initialize, "") }.should raise_error(SecurityError)
-> { //.send(:initialize, "") }.should raise_error(SecurityError)
end
it "raises a TypeError on an initialized non-literal Regexp" do
lambda { Regexp.new("").send(:initialize, "") }.should raise_error(TypeError)
-> { Regexp.new("").send(:initialize, "") }.should raise_error(TypeError)
end
end

View file

@ -35,7 +35,7 @@ describe "Regexp#match" do
end
it "raises a TypeError on an uninitialized Regexp" do
lambda { Regexp.allocate.match('foo') }.should raise_error(TypeError)
-> { Regexp.allocate.match('foo') }.should raise_error(TypeError)
end
describe "with [string, position]" do
@ -50,7 +50,7 @@ describe "Regexp#match" do
it "raises an ArgumentError for an invalid encoding" do
x96 = ([150].pack('C')).force_encoding('utf-8')
lambda { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should raise_error(ArgumentError)
-> { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should raise_error(ArgumentError)
end
end
@ -65,7 +65,7 @@ describe "Regexp#match" do
it "raises an ArgumentError for an invalid encoding" do
x96 = ([150].pack('C')).force_encoding('utf-8')
lambda { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should raise_error(ArgumentError)
-> { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should raise_error(ArgumentError)
end
end
@ -98,12 +98,12 @@ describe "Regexp#match" do
it "raises TypeError when the given argument cannot be coerced to String" do
f = 1
lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
-> { /foo/.match(f)[0] }.should raise_error(TypeError)
end
it "raises TypeError when the given argument is an Exception" do
f = Exception.new("foo")
lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
-> { /foo/.match(f)[0] }.should raise_error(TypeError)
end
end

View file

@ -16,12 +16,12 @@ end
describe "Regexp.new given a Fixnum" do
it "raises a TypeError" do
lambda { Regexp.new(1) }.should raise_error(TypeError)
-> { Regexp.new(1) }.should raise_error(TypeError)
end
end
describe "Regexp.new given a Float" do
it "raises a TypeError" do
lambda { Regexp.new(1.0) }.should raise_error(TypeError)
-> { Regexp.new(1.0) }.should raise_error(TypeError)
end
end

View file

@ -29,7 +29,7 @@ describe "Regexp#options" do
end
it "raises a TypeError on an uninitialized Regexp" do
lambda { Regexp.allocate.options }.should raise_error(TypeError)
-> { Regexp.allocate.options }.should raise_error(TypeError)
end
it "includes Regexp::FIXEDENCODING for a Regexp literal with the 'u' option" do

View file

@ -30,7 +30,7 @@ describe :regexp_new_string, shared: true do
end
it "raises a RegexpError when passed an incorrect regexp" do
lambda { Regexp.send(@method, "^[$", 0) }.should raise_error(RegexpError)
-> { Regexp.send(@method, "^[$", 0) }.should raise_error(RegexpError)
end
it "does not set Regexp options if only given one argument" do
@ -98,7 +98,7 @@ describe :regexp_new_string, shared: true do
end
it "ignores the third argument if it is 'e' or 'euc' (case-insensitive)" do
lambda {
-> {
Regexp.send(@method, 'Hi', nil, 'e').encoding.should == Encoding::US_ASCII
Regexp.send(@method, 'Hi', nil, 'euc').encoding.should == Encoding::US_ASCII
Regexp.send(@method, 'Hi', nil, 'E').encoding.should == Encoding::US_ASCII
@ -107,7 +107,7 @@ describe :regexp_new_string, shared: true do
end
it "ignores the third argument if it is 's' or 'sjis' (case-insensitive)" do
lambda {
-> {
Regexp.send(@method, 'Hi', nil, 's').encoding.should == Encoding::US_ASCII
Regexp.send(@method, 'Hi', nil, 'sjis').encoding.should == Encoding::US_ASCII
Regexp.send(@method, 'Hi', nil, 'S').encoding.should == Encoding::US_ASCII
@ -116,7 +116,7 @@ describe :regexp_new_string, shared: true do
end
it "ignores the third argument if it is 'u' or 'utf8' (case-insensitive)" do
lambda {
-> {
Regexp.send(@method, 'Hi', nil, 'u').encoding.should == Encoding::US_ASCII
Regexp.send(@method, 'Hi', nil, 'utf8').encoding.should == Encoding::US_ASCII
Regexp.send(@method, 'Hi', nil, 'U').encoding.should == Encoding::US_ASCII
@ -143,11 +143,11 @@ describe :regexp_new_string, shared: true do
describe "with escaped characters" do
it "raises a Regexp error if there is a trailing backslash" do
lambda { Regexp.send(@method, "\\") }.should raise_error(RegexpError)
-> { Regexp.send(@method, "\\") }.should raise_error(RegexpError)
end
it "does not raise a Regexp error if there is an escaped trailing backslash" do
lambda { Regexp.send(@method, "\\\\") }.should_not raise_error(RegexpError)
-> { Regexp.send(@method, "\\\\") }.should_not raise_error(RegexpError)
end
it "accepts a backspace followed by a character" do
@ -175,7 +175,7 @@ describe :regexp_new_string, shared: true do
end
it "raises a RegexpError if \\x is not followed by any hexadecimal digits" do
lambda { Regexp.send(@method, "\\" + "xn") }.should raise_error(RegexpError)
-> { Regexp.send(@method, "\\" + "xn") }.should raise_error(RegexpError)
end
it "accepts an escaped string interpolation" do
@ -331,15 +331,15 @@ describe :regexp_new_string, shared: true do
end
it "raises a RegexpError if less than four digits are given for \\uHHHH" do
lambda { Regexp.send(@method, "\\" + "u304") }.should raise_error(RegexpError)
-> { Regexp.send(@method, "\\" + "u304") }.should raise_error(RegexpError)
end
it "raises a RegexpError if the \\u{} escape is empty" do
lambda { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError)
-> { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError)
end
it "raises a RegexpError if more than six hexadecimal digits are given" do
lambda { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError)
-> { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError)
end
it "returns a Regexp with US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do
@ -475,7 +475,7 @@ describe :regexp_new_regexp, shared: true do
it "does not honour options given as additional arguments" do
r = nil
lambda {
-> {
r = Regexp.send @method, /hi/, Regexp::IGNORECASE
}.should complain(/flags ignored/)
(r.options & Regexp::IGNORECASE).should == 0

View file

@ -52,83 +52,83 @@ describe "Regexp.union" do
end
it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Strings" do
lambda {
-> {
Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-16BE"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Regexps" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-16LE")),
Regexp.new("b".encode("UTF-16BE")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include conflicting fixed encoding Regexps" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING),
Regexp.new("b".encode("US-ASCII"), Regexp::FIXEDENCODING))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include a fixed encoding Regexp and a String containing non-ASCII-compatible characters in a different encoding" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING),
"\u00A9".encode("ISO-8859-1"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include a String containing non-ASCII-compatible characters and a fixed encoding Regexp in a different encoding" do
lambda {
-> {
Regexp.union("\u00A9".encode("ISO-8859-1"),
Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only String" do
lambda {
-> {
Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-8"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only String" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), "b".encode("UTF-8"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only Regexp" do
lambda {
-> {
Regexp.union("a".encode("UTF-16LE"), Regexp.new("b".encode("UTF-8")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only Regexp" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("b".encode("UTF-8")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and a String containing non-ASCII-compatible characters in a different encoding" do
lambda {
-> {
Regexp.union("a".encode("UTF-16LE"), "\u00A9".encode("ISO-8859-1"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a String containing non-ASCII-compatible characters in a different encoding" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), "\u00A9".encode("ISO-8859-1"))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible String and a Regexp containing non-ASCII-compatible characters in a different encoding" do
lambda {
-> {
Regexp.union("a".encode("UTF-16LE"), Regexp.new("\u00A9".encode("ISO-8859-1")))
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a Regexp containing non-ASCII-compatible characters in a different encoding" do
lambda {
-> {
Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("\u00A9".encode("ISO-8859-1")))
}.should raise_error(ArgumentError)
end
@ -144,6 +144,6 @@ describe "Regexp.union" do
not_supported_on :opal do
Regexp.union([/dogs/, /cats/i]).should == /(?-mix:dogs)|(?i-mx:cats)/
end
lambda{Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i])}.should raise_error(TypeError)
->{Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i])}.should raise_error(TypeError)
end
end