spec/regexp-examples_spec.rb in regexp-examples-0.5.3 vs spec/regexp-examples_spec.rb in regexp-examples-0.5.4
- old
+ new
@@ -126,10 +126,17 @@
/(a|(b)) \2/,
/([ab]){2} \1/ # \1 should always be the LAST result of the capture group
)
end
+ context "for escaped octal characters" do
+ examples_exist_and_match(
+ /\10\20\30\40\50/,
+ /\177123/ # Should work for numbers up to 177
+ )
+ end
+
context "for complex patterns" do
# Longer combinations of the above
examples_exist_and_match(
/https?:\/\/(www\.)github\.com/,
/(I(N(C(E(P(T(I(O(N)))))))))*/,
@@ -238,9 +245,16 @@
it { expect(/(a|b){2}/.examples).to eq ["aa", "ab", "ba", "bb"] }
it { expect(/a+|b?/.examples).to eq ["a", "aa", "aaa", "", "b"] }
# a{1}? should be equivalent to (?:a{1})?, i.e. NOT a "non-greedy quantifier"
it { expect(/a{1}?/.examples).to eq ["", "a"] }
+ end
+
+ context "backreferences and escaped octal combined" do
+ it do
+ expect(/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)? \10\9\8\7\6\5\4\3\2\1/.examples)
+ .to eq ["abcdefghi \x08ihgfedcba", "abcdefghij jihgfedcba"]
+ end
end
context "max_repeater_variance config option" do
it do
expect(/a+/.examples(max_repeater_variance: 5))