summaryrefslogtreecommitdiff
path: root/tests/test_builtin.js
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2024-01-10 14:36:19 +0100
committerFabrice Bellard <fabrice@bellard.org>2024-01-10 14:36:19 +0100
commit10fc744ae4dfe59b685f5643b71530891cf0be3b (patch)
tree3d94d16a2e6f7b3d4c843919ee8326cebe9c4f0f /tests/test_builtin.js
parentf25e5d4094a11cf098670417e8a16ffb7cbadda0 (diff)
downloadquickjs-10fc744ae4dfe59b685f5643b71530891cf0be3b.tar.gz
quickjs-10fc744ae4dfe59b685f5643b71530891cf0be3b.zip
regexp: fixed the zero advance logic in quantifiers (github issue #158)
Diffstat (limited to 'tests/test_builtin.js')
-rw-r--r--tests/test_builtin.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test_builtin.js b/tests/test_builtin.js
index 0b310c0..e256066 100644
--- a/tests/test_builtin.js
+++ b/tests/test_builtin.js
@@ -538,7 +538,17 @@ function test_regexp()
assert(/{1a}/.toString(), "/{1a}/");
a = /a{1+/.exec("a{11");
- assert(a, ["a{11"] );
+ assert(a, ["a{11"]);
+
+ /* test zero length matches */
+ a = /(?:(?=(abc)))a/.exec("abc");
+ assert(a, ["a", "abc"]);
+ a = /(?:(?=(abc)))?a/.exec("abc");
+ assert(a, ["a", undefined]);
+ a = /(?:(?=(abc))){0,2}a/.exec("abc");
+ assert(a, ["a", undefined]);
+ a = /(?:|[\w])+([0-9])/.exec("123a23");
+ assert(a, ["123a23", "3"]);
}
function test_symbol()