lib/regextest.rb in regextest-0.1.5 vs lib/regextest.rb in regextest-0.1.6
- old
+ new
@@ -70,12 +70,15 @@
# @return [String] if matched without verification (i.e. return unverified matched string).
# @return [nil] nil if failed to generate
# @raise [RuntimeError] if something wrong...
# @raise [Regextest::RegextestTimeout] if detected timeout while verification. Option 'verification: false' may be workaround.
def generate
- TstConstRetryMax.times do | retry_count |
-
+ start_time = Time.now
+ 0.step(TstFixnumMax) do | retry_count |
+ duration = Time.now - start_time
+ break if retry_count >= TstConstRetryMax && duration >= TstConstRetryMaxSecond
+
# generate string
reset_random_called
@result = @back_end.generate(retry_count)
if !@result
TstLog "NG: Failed to generate"
@@ -112,10 +115,11 @@
# Get parsed result as JSON string
# @return [String] parsed result as JSON string
def to_json
@front_end.get_json_string
end
+
#---------------#
private
# Set seed for randomizing
def set_seed_for_randomizing(seed)
@@ -141,10 +145,10 @@
@reg_exp = /#{@reg_string}/
end
when Regexp
@reg_exp = param
@@parse_options[:reg_options].set(@reg_exp.options) # inner regex options have priorty
- @reg_string = "#{@reg_exp}" # this generates string with options
+ @reg_string = @@parse_options[:reg_options].prefix_reg + @reg_exp.source
else
raise "Error: string or regular expression required"
end
@@parse_options[:reg_source] = @reg_string
end