mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
874 B
50 lines
874 B
/*
|
|
* Regexp bug reported by Conrad Pankoff.
|
|
*
|
|
* Duktape 0.9.0 compiled /(?:a)?/ incorrectly. The regexp bytecode was
|
|
* essentially matching /a(?:)?/ instead, because the "previous atom"
|
|
* state was incorrectly updated for non-capturing groups.
|
|
*/
|
|
|
|
/*===
|
|
false
|
|
false
|
|
false
|
|
true
|
|
true
|
|
true
|
|
true
|
|
true
|
|
true
|
|
true
|
|
true
|
|
true
|
|
===*/
|
|
|
|
function regexpNoncapturingTest() {
|
|
// should be false
|
|
print(/a/.test("x"));
|
|
print(/(a)/.test("x"));
|
|
print(/(?:a)/.test("x"));
|
|
|
|
// should be true
|
|
print(/a/.test("a"));
|
|
print(/(a)/.test("a"));
|
|
print(/(?:a)/.test("a"));
|
|
|
|
// should be true
|
|
print(/a?/.test("x"));
|
|
print(/(a)?/.test("x"));
|
|
print(/(?:a)?/.test("x"));
|
|
|
|
// should be true
|
|
print(/a?/.test("a"));
|
|
print(/(a)?/.test("a"));
|
|
print(/(?:a)?/.test("a"));
|
|
}
|
|
|
|
try {
|
|
regexpNoncapturingTest();
|
|
} catch (e) {
|
|
print(e);
|
|
}
|
|
|