Closed postmodern closed 4 months ago
IMO a gem/app should not test for this exact exception message, this message is subject to change, even in CRuby.
An easy fix/workaround for that would be to test for message.include? 'premature end of char-class'
Probably we should not include the Java exception class there, OTOH I'm pretty sure it could be useful or clearer in some cases e.g. if an ArrayIndexOutOfBoundsException
or so happens inside Joni (IIRC that already happened).
@eregon I discovered this divergent behavior when some of my code re-raised a RegexpError
as an OptionParser::InvalidArgument
exception. RSpec also insists on testing both the exception class and the exception message. I could have defined a clever regex to match both CRuby's and TruffleRuby's RegexpError
exception message, but the TruffleRuby specific information about the Java class appears directly in the middle of the exception message; plus the goal is to avoid adding TruffleRuby/Java specific logic. Feel free to send me a better PR, or change the RegexpError
message to not include the Java class name.
https://github.com/ronin-rb/ronin/blob/3fe7602913b54a5d0a592d4a95b32a50d48b1375/spec/cli/commands/dns_proxy_spec.rb#L127-L136
Fixed in 7d3feadef32d7c24028a01ed8868ddd01a1ae857.
I noticed that
Regexp.new(...)
raises a slightly differentRegexpError
exception message when it cannot parse the regular expression. This causes certain tests that check the exception message to fail when ran under TruffleRuby.Steps To Reproduce
CRuby
TruffleRuby
Version Information