Commit 4: Curate corpus for C++ ECMAScript; regenerate .expected

Content-only edits to test.cpp to remove Ruby-only syntax that has no
C++ ECMAScript equivalent:

1. Removed: "a{,8}" — Ruby-only "{,n}" no-lower-bound quantifier
   (ECMAScript requires an explicit lower bound in {n,m})

2. Removed: second ".*" for /.*/m — mode flags in C++ are construction-site
   arguments (e.g. std::regex::multiline), not part of the pattern string.
   This mode variant was the exact same pattern string as r_meta1 so it
   added no coverage.

3. Removed: "(?'foo'fo+)" — Ruby single-quote named-group form.
   ECMAScript only supports the angle-bracket form (?<name>...).

Left in place for now (removed with the parser in commit 5):
  \\A, \\z, \\G, \\h, \\H — Ruby-only anchor/escape classes.
  The POSIX-bracket cases are kept through commit 7.

.expected regenerated by:
  codeql test run --learn --search-path=. cpp/ql/test/library-tests/regex/
  (CodeQL CLI 2.26.1)
All 2 tests passed.
This commit is contained in:
copilot-swe-agent[bot]
2026-07-21 10:12:21 +00:00
committed by GitHub
parent d7a8f48c1c
commit 96c7e2dbc5
3 changed files with 3 additions and 41 deletions

View File

@@ -29,11 +29,6 @@ test.cpp:
# 35| [RegExpRange] a{4,8}
#-----| 0 -> [RegExpConstant, RegExpNormalChar] a
# 36| [RegExpConstant, RegExpNormalChar] a
# 36| [RegExpRange] a{,8}
#-----| 0 -> [RegExpConstant, RegExpNormalChar] a
# 37| [RegExpConstant, RegExpNormalChar] a
# 37| [InfiniteRepetitionQuantifier, RegExpRange] a{3,}
@@ -202,11 +197,6 @@ test.cpp:
# 59| [RegExpStar] .*
#-----| 0 -> [RegExpDot] .
# 60| [RegExpDot] .
# 60| [RegExpStar] .*
#-----| 0 -> [RegExpDot] .
# 61| [RegExpCharacterClassEscape] \w
# 61| [RegExpPlus] \w+
@@ -348,20 +338,6 @@ test.cpp:
# 78| [RegExpPlus] \w+
#-----| 0 -> [RegExpCharacterClassEscape] \w
# 79| [RegExpGroup] (?'foo'fo+)
#-----| 0 -> [RegExpSequence] fo+
# 79| [RegExpConstant, RegExpNormalChar] f
# 79| [RegExpSequence] fo+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] f
#-----| 1 -> [RegExpPlus] o+
# 79| [RegExpConstant, RegExpNormalChar] o
# 79| [RegExpPlus] o+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] o
# 82| [RegExpGroup] (a+)
#-----| 0 -> [RegExpPlus] a+

View File

@@ -1,12 +1,10 @@
groupName
| test.cpp:78:21:78:30 | (?<id>\\w+) | id |
| test.cpp:79:21:79:31 | (?'foo'fo+) | foo |
| test.cpp:83:23:83:32 | (?<qux>q+) | qux |
groupNumber
| test.cpp:72:22:72:26 | (foo) | 1 |
| test.cpp:73:24:73:28 | (o\|b) | 1 |
| test.cpp:74:22:74:29 | (a\|b\|cd) | 1 |
| test.cpp:79:21:79:31 | (?'foo'fo+) | 1 |
| test.cpp:82:23:82:26 | (a+) | 1 |
term
| test.cpp:31:21:31:23 | abc | RegExpConstant,RegExpNormalChar |
@@ -20,8 +18,6 @@ term
| test.cpp:34:28:34:28 | d | RegExpConstant,RegExpNormalChar |
| test.cpp:35:22:35:22 | a | RegExpConstant,RegExpNormalChar |
| test.cpp:35:22:35:27 | a{4,8} | RegExpRange |
| test.cpp:36:22:36:22 | a | RegExpConstant,RegExpNormalChar |
| test.cpp:36:22:36:26 | a{,8} | RegExpRange |
| test.cpp:37:22:37:22 | a | RegExpConstant,RegExpNormalChar |
| test.cpp:37:22:37:26 | a{3,} | InfiniteRepetitionQuantifier,RegExpRange |
| test.cpp:38:22:38:22 | a | RegExpConstant,RegExpNormalChar |
@@ -83,8 +79,6 @@ term
| test.cpp:56:30:56:33 | A-F] | RegExpConstant,RegExpNormalChar |
| test.cpp:59:23:59:23 | . | RegExpDot |
| test.cpp:59:23:59:24 | .* | RegExpStar |
| test.cpp:60:24:60:24 | . | RegExpDot |
| test.cpp:60:24:60:25 | .* | RegExpStar |
| test.cpp:61:23:61:24 | \\w | RegExpCharacterClassEscape |
| test.cpp:61:23:61:25 | \\w+ | RegExpPlus |
| test.cpp:61:23:61:27 | \\w+\\W | RegExpSequence |
@@ -136,11 +130,6 @@ term
| test.cpp:78:21:78:30 | (?<id>\\w+) | RegExpGroup |
| test.cpp:78:27:78:28 | \\w | RegExpCharacterClassEscape |
| test.cpp:78:27:78:29 | \\w+ | RegExpPlus |
| test.cpp:79:21:79:31 | (?'foo'fo+) | RegExpGroup |
| test.cpp:79:28:79:28 | f | RegExpConstant,RegExpNormalChar |
| test.cpp:79:28:79:30 | fo+ | RegExpSequence |
| test.cpp:79:29:79:29 | o | RegExpConstant,RegExpNormalChar |
| test.cpp:79:29:79:30 | o+ | RegExpPlus |
| test.cpp:82:23:82:26 | (a+) | RegExpGroup |
| test.cpp:82:23:82:30 | (a+)b+\\1 | RegExpSequence |
| test.cpp:82:24:82:24 | a | RegExpConstant,RegExpNormalChar |
@@ -193,7 +182,6 @@ regExpNormalCharValue
| test.cpp:34:26:34:26 | c | c |
| test.cpp:34:28:34:28 | d | d |
| test.cpp:35:22:35:22 | a | a |
| test.cpp:36:22:36:22 | a | a |
| test.cpp:37:22:37:22 | a | a |
| test.cpp:38:22:38:22 | a | a |
| test.cpp:41:21:41:23 | foo | foo |
@@ -253,8 +241,6 @@ regExpNormalCharValue
| test.cpp:75:25:75:25 | : | : |
| test.cpp:75:28:75:29 | \\w | w |
| test.cpp:78:27:78:28 | \\w | w |
| test.cpp:79:28:79:28 | f | f |
| test.cpp:79:29:79:29 | o | o |
| test.cpp:82:24:82:24 | a | a |
| test.cpp:82:27:82:27 | b | b |
| test.cpp:83:30:83:30 | q | q |

View File

@@ -33,7 +33,7 @@ void test() {
// Repetition
std::regex r_rep1("a*b+c?d");
std::regex r_rep2("a{4,8}");
std::regex r_rep3("a{,8}");
// Removed: a{,8} — Ruby-only "{,n}" no-lower-bound quantifier (not in ECMAScript)
std::regex r_rep4("a{3,}");
std::regex r_rep5("a{7}");
@@ -57,7 +57,7 @@ void test() {
// Meta-character classes
std::regex r_meta1(".*");
std::regex r_meta1m(".*"); // /.*/m mode variant — mode flags are constructor args in C++
// Removed: /.*/m mode variant — in C++, flags are passed as constructor arg (out of scope)
std::regex r_meta2("\\w+\\W");
std::regex r_meta3("\\s\\S");
std::regex r_meta4("\\d\\D");
@@ -76,7 +76,7 @@ void test() {
// Named groups
std::regex r_ng1("(?<id>\\w+)");
std::regex r_ng2("(?'foo'fo+)"); // single-quote named-group form
// Removed: (?'foo'fo+) — Ruby single-quote named-group form (not in ECMAScript)
// Backreferences
std::regex r_bref1("(a+)b+\\1");