Skip to content

Commit 96c7e2d

Browse files
authored
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.
1 parent d7a8f48 commit 96c7e2d

3 files changed

Lines changed: 3 additions & 41 deletions

File tree

cpp/ql/test/library-tests/regex/parse.expected

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ test.cpp:
2929
# 35| [RegExpRange] a{4,8}
3030
#-----| 0 -> [RegExpConstant, RegExpNormalChar] a
3131

32-
# 36| [RegExpConstant, RegExpNormalChar] a
33-
34-
# 36| [RegExpRange] a{,8}
35-
#-----| 0 -> [RegExpConstant, RegExpNormalChar] a
36-
3732
# 37| [RegExpConstant, RegExpNormalChar] a
3833

3934
# 37| [InfiniteRepetitionQuantifier, RegExpRange] a{3,}
@@ -202,11 +197,6 @@ test.cpp:
202197
# 59| [RegExpStar] .*
203198
#-----| 0 -> [RegExpDot] .
204199

205-
# 60| [RegExpDot] .
206-
207-
# 60| [RegExpStar] .*
208-
#-----| 0 -> [RegExpDot] .
209-
210200
# 61| [RegExpCharacterClassEscape] \w
211201

212202
# 61| [RegExpPlus] \w+
@@ -348,20 +338,6 @@ test.cpp:
348338
# 78| [RegExpPlus] \w+
349339
#-----| 0 -> [RegExpCharacterClassEscape] \w
350340

351-
# 79| [RegExpGroup] (?'foo'fo+)
352-
#-----| 0 -> [RegExpSequence] fo+
353-
354-
# 79| [RegExpConstant, RegExpNormalChar] f
355-
356-
# 79| [RegExpSequence] fo+
357-
#-----| 0 -> [RegExpConstant, RegExpNormalChar] f
358-
#-----| 1 -> [RegExpPlus] o+
359-
360-
# 79| [RegExpConstant, RegExpNormalChar] o
361-
362-
# 79| [RegExpPlus] o+
363-
#-----| 0 -> [RegExpConstant, RegExpNormalChar] o
364-
365341
# 82| [RegExpGroup] (a+)
366342
#-----| 0 -> [RegExpPlus] a+
367343

cpp/ql/test/library-tests/regex/regexp.expected

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
groupName
22
| test.cpp:78:21:78:30 | (?<id>\\w+) | id |
3-
| test.cpp:79:21:79:31 | (?'foo'fo+) | foo |
43
| test.cpp:83:23:83:32 | (?<qux>q+) | qux |
54
groupNumber
65
| test.cpp:72:22:72:26 | (foo) | 1 |
76
| test.cpp:73:24:73:28 | (o\|b) | 1 |
87
| test.cpp:74:22:74:29 | (a\|b\|cd) | 1 |
9-
| test.cpp:79:21:79:31 | (?'foo'fo+) | 1 |
108
| test.cpp:82:23:82:26 | (a+) | 1 |
119
term
1210
| test.cpp:31:21:31:23 | abc | RegExpConstant,RegExpNormalChar |
@@ -20,8 +18,6 @@ term
2018
| test.cpp:34:28:34:28 | d | RegExpConstant,RegExpNormalChar |
2119
| test.cpp:35:22:35:22 | a | RegExpConstant,RegExpNormalChar |
2220
| test.cpp:35:22:35:27 | a{4,8} | RegExpRange |
23-
| test.cpp:36:22:36:22 | a | RegExpConstant,RegExpNormalChar |
24-
| test.cpp:36:22:36:26 | a{,8} | RegExpRange |
2521
| test.cpp:37:22:37:22 | a | RegExpConstant,RegExpNormalChar |
2622
| test.cpp:37:22:37:26 | a{3,} | InfiniteRepetitionQuantifier,RegExpRange |
2723
| test.cpp:38:22:38:22 | a | RegExpConstant,RegExpNormalChar |
@@ -83,8 +79,6 @@ term
8379
| test.cpp:56:30:56:33 | A-F] | RegExpConstant,RegExpNormalChar |
8480
| test.cpp:59:23:59:23 | . | RegExpDot |
8581
| test.cpp:59:23:59:24 | .* | RegExpStar |
86-
| test.cpp:60:24:60:24 | . | RegExpDot |
87-
| test.cpp:60:24:60:25 | .* | RegExpStar |
8882
| test.cpp:61:23:61:24 | \\w | RegExpCharacterClassEscape |
8983
| test.cpp:61:23:61:25 | \\w+ | RegExpPlus |
9084
| test.cpp:61:23:61:27 | \\w+\\W | RegExpSequence |
@@ -136,11 +130,6 @@ term
136130
| test.cpp:78:21:78:30 | (?<id>\\w+) | RegExpGroup |
137131
| test.cpp:78:27:78:28 | \\w | RegExpCharacterClassEscape |
138132
| test.cpp:78:27:78:29 | \\w+ | RegExpPlus |
139-
| test.cpp:79:21:79:31 | (?'foo'fo+) | RegExpGroup |
140-
| test.cpp:79:28:79:28 | f | RegExpConstant,RegExpNormalChar |
141-
| test.cpp:79:28:79:30 | fo+ | RegExpSequence |
142-
| test.cpp:79:29:79:29 | o | RegExpConstant,RegExpNormalChar |
143-
| test.cpp:79:29:79:30 | o+ | RegExpPlus |
144133
| test.cpp:82:23:82:26 | (a+) | RegExpGroup |
145134
| test.cpp:82:23:82:30 | (a+)b+\\1 | RegExpSequence |
146135
| test.cpp:82:24:82:24 | a | RegExpConstant,RegExpNormalChar |
@@ -193,7 +182,6 @@ regExpNormalCharValue
193182
| test.cpp:34:26:34:26 | c | c |
194183
| test.cpp:34:28:34:28 | d | d |
195184
| test.cpp:35:22:35:22 | a | a |
196-
| test.cpp:36:22:36:22 | a | a |
197185
| test.cpp:37:22:37:22 | a | a |
198186
| test.cpp:38:22:38:22 | a | a |
199187
| test.cpp:41:21:41:23 | foo | foo |
@@ -253,8 +241,6 @@ regExpNormalCharValue
253241
| test.cpp:75:25:75:25 | : | : |
254242
| test.cpp:75:28:75:29 | \\w | w |
255243
| test.cpp:78:27:78:28 | \\w | w |
256-
| test.cpp:79:28:79:28 | f | f |
257-
| test.cpp:79:29:79:29 | o | o |
258244
| test.cpp:82:24:82:24 | a | a |
259245
| test.cpp:82:27:82:27 | b | b |
260246
| test.cpp:83:30:83:30 | q | q |

cpp/ql/test/library-tests/regex/test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void test() {
3333
// Repetition
3434
std::regex r_rep1("a*b+c?d");
3535
std::regex r_rep2("a{4,8}");
36-
std::regex r_rep3("a{,8}");
36+
// Removed: a{,8} — Ruby-only "{,n}" no-lower-bound quantifier (not in ECMAScript)
3737
std::regex r_rep4("a{3,}");
3838
std::regex r_rep5("a{7}");
3939

@@ -57,7 +57,7 @@ void test() {
5757

5858
// Meta-character classes
5959
std::regex r_meta1(".*");
60-
std::regex r_meta1m(".*"); // /.*/m mode variant — mode flags are constructor args in C++
60+
// Removed: /.*/m mode variant — in C++, flags are passed as constructor arg (out of scope)
6161
std::regex r_meta2("\\w+\\W");
6262
std::regex r_meta3("\\s\\S");
6363
std::regex r_meta4("\\d\\D");
@@ -76,7 +76,7 @@ void test() {
7676

7777
// Named groups
7878
std::regex r_ng1("(?<id>\\w+)");
79-
std::regex r_ng2("(?'foo'fo+)"); // single-quote named-group form
79+
// Removed: (?'foo'fo+) — Ruby single-quote named-group form (not in ECMAScript)
8080

8181
// Backreferences
8282
std::regex r_bref1("(a+)b+\\1");

0 commit comments

Comments
 (0)