Skip to content

Commit 66a16d2

Browse files
committed
JS: Fix buggy test cases
1 parent 2d53416 commit 66a16d2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

javascript/ql/test/query-tests/RegExp/RegExpAlwaysMatches/RegExpAlwaysMatches.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
| tst.js:22:11:22:34 | ^(?:https?:\|ftp:\|file:)? | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:22:10:22:43 | /^(?:ht ... test(x) | here |
44
| tst.js:30:11:30:20 | (foo\|bar)? | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:30:10:30:29 | /(foo\|bar)?/.test(x) | here |
55
| tst.js:34:21:34:26 | (baz)? | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:34:10:34:35 | /^foo\|b ... test(x) | here |
6+
| tst.js:58:20:58:25 | [a-z]* | This regular expression always the matches at index 0 when used $@, as it matches the empty substring. | tst.js:58:10:58:27 | x.search(/[a-z]*/) | here |
7+
| tst.js:70:20:70:26 | ^(foo)? | This regular expression always the matches at index 0 when used $@, as it matches the empty substring. | tst.js:70:10:70:28 | x.search(/^(foo)?/) | here |
68
| tst.js:86:22:86:21 | | This regular expression always matches when used in a test $@, as it can match an empty substring. | tst.js:86:10:86:31 | new Reg ... test(x) | here |

javascript/ql/test/query-tests/RegExp/RegExpAlwaysMatches/tst.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,23 @@ function emptyAlt3(x) {
5555
}
5656

5757
function search(x) {
58-
return /[a-z]*/.search(x); // NOT OK
58+
return x.search(/[a-z]*/); // NOT OK
5959
}
6060

6161
function search2(x) {
62-
return /[a-z]/.search(x); // OK
62+
return x.search(/[a-z]/); // OK
6363
}
6464

6565
function lookahead(x) {
66-
return /(?!x)/.search(x); // OK
66+
return x.search(/(?!x)/); // OK
6767
}
6868

6969
function searchPrefix(x) {
70-
return /^foo?/.search(x); // NOT OK - `foo?` does not affect the returned index
70+
return x.search(/^(foo)?/); // NOT OK - `foo?` does not affect the returned index
7171
}
7272

7373
function searchSuffix(x) {
74-
return /foo?$/.search(x); // OK - `foo?` affects the returned index
74+
return x.search(/(foo)?$/); // OK - `foo?` affects the returned index
7575
}
7676

7777
function wordBoundary(x) {

0 commit comments

Comments
 (0)