Skip to content

Commit

Permalink
Add spec for regexp compilation with invalid characters
Browse files Browse the repository at this point in the history
This is different from the code path of too many characters (resulting
in a different error message) and might be a different implementation
from the "no characters" error.
  • Loading branch information
herwinw authored and eregon committed Oct 5, 2024
1 parent 2bfa245 commit 4b074c7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/regexp/shared/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ def obj.to_int() ScratchPad.record(:called) end
-> { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode list: /\\u{}/")))
end

it "raises a RegexpError if the \\u{} escape contains non hexadecimal digits" do
-> { Regexp.send(@method, "\\" + "u{abcX}") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode list: /\\u{abcX}/")))
end

it "raises a RegexpError if more than six hexadecimal digits are given" do
-> { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode range: /\\u{0ffffff}/")))
end
Expand Down

0 comments on commit 4b074c7

Please sign in to comment.