tom-lord / regexp-examples

Generate strings that match a given regular expression
MIT License
520 stars 31 forks source link

Use the dynamically called result type, not statically defined one #26

Closed tom-lord closed 6 years ago

tom-lord commented 6 years ago

Fixes https://github.com/tom-lord/regexp-examples/issues/21

The subtle issue here is that __method__ was referencing the statically defined method name (in this case, always result), whereas __callee__ references the dynamically called method name (in this case, random_result).

Usually, __callee__ is the same as __method__. But in some situations - such as here, where I've used alias - it's different.

The upshot of this is that previous versions of the gem may have had a limited results set to choose a "random example" from; in particular if the regex contained a "MultiGroup" (anything with brackets), and the number of possible results within those brackets was over 10,000 (the default max_results_limit).

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 8140e2c0d48bfbe4a6388690e7bf4b1ca515b0c3 on fix_random_example_dataset_regression into 42e1afcc238dbf5bdbd86fc4358cef335409816b on master.