Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/net/imap/regexp_collector.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class RegexpCollector
Data = Net::IMAP::Data

ConstantRegexp = Data.define(:mod, :const_name, :regexp) do
def name = "%s::%s" % [mod, const_name]
end
Expand Down
10 changes: 7 additions & 3 deletions test/net/imap/test_regexps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require "net/imap"
require "test/unit"

return unless Regexp.respond_to?(:linear_time?)

begin
require_relative "regexp_collector"
rescue LoadError
Expand Down Expand Up @@ -34,7 +32,13 @@ class IMAPRegexpsTest < Test::Unit::TestCase
)

def test_linear_time(data)
assert Regexp.linear_time?(data.regexp)
regexp = data.regexp
assert Regexp.linear_time?(regexp), "%p might backtrack" % [regexp]
rescue NoMethodError
pend "Regexp.linear_time? not implemented by #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION}"
rescue Test::Unit::AssertionFailedError
raise if RUBY_ENGINE == "ruby"
pend "%p might backtrack in %s %s" % [regexp, RUBY_ENGINE, RUBY_ENGINE_VERSION]
end

end
Loading