Skip to content

Commit 801e8e3

Browse files
committed
Test lastIndex calculation for exec calls
JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent 41aef56 commit 801e8e3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/jerry/regexp-routines.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,21 @@ catch (e)
4848
{
4949
assert (e instanceof TypeError);
5050
}
51+
52+
53+
/* Test continous calls to the exec method to see how does the match
54+
* updates the lastIndex propertyand see if the match restarts.
55+
*/
56+
var re = new RegExp("a", "g");
57+
result = re.exec("a");
58+
assert (result.length === 1);
59+
assert (result[0] === "a");
60+
assert (re.lastIndex === 1);
61+
62+
assert (re.exec("a") === null);
63+
assert (re.lastIndex === 0);
64+
65+
result = re.exec("a");
66+
assert (result.length === 1);
67+
assert (result[0] === "a");
68+
assert (re.lastIndex === 1);

0 commit comments

Comments
 (0)