From 801e8e34cdd5e4641e7d0f909035ada419b0f363 Mon Sep 17 00:00:00 2001 From: Peter Gal Date: Mon, 20 Jul 2015 19:44:18 +0200 Subject: [PATCH] Test lastIndex calculation for exec calls JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com --- tests/jerry/regexp-routines.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/jerry/regexp-routines.js b/tests/jerry/regexp-routines.js index b2e5335b7..0c1a6df28 100644 --- a/tests/jerry/regexp-routines.js +++ b/tests/jerry/regexp-routines.js @@ -48,3 +48,21 @@ catch (e) { assert (e instanceof TypeError); } + + +/* Test continous calls to the exec method to see how does the match + * updates the lastIndex propertyand see if the match restarts. + */ +var re = new RegExp("a", "g"); +result = re.exec("a"); +assert (result.length === 1); +assert (result[0] === "a"); +assert (re.lastIndex === 1); + +assert (re.exec("a") === null); +assert (re.lastIndex === 0); + +result = re.exec("a"); +assert (result.length === 1); +assert (result[0] === "a"); +assert (re.lastIndex === 1);