Skip to content

Commit 61764dc

Browse files
committed
Add spec for matching a Regexp against a broken String
* Fix the exception message in TruffleRuby.
1 parent fdc534b commit 61764dc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

language/regexp/encoding_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129
-> { Regexp.new("".force_encoding("US-ASCII"), Regexp::FIXEDENCODING) =~ "\303\251".force_encoding('UTF-8') }.should raise_error(Encoding::CompatibilityError)
130130
end
131131

132+
it "raises ArgumentError when trying to match a broken String" do
133+
s = "\x80".force_encoding('UTF-8')
134+
-> { s =~ /./ }.should raise_error(ArgumentError, "invalid byte sequence in UTF-8")
135+
end
132136

133137
it "computes the Regexp Encoding for each interpolated Regexp instance" do
134138
make_regexp = -> str { /#{str}/ }

0 commit comments

Comments
 (0)