Test lastIndex calculation for exec calls

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Peter Gal
2015-07-20 19:44:18 +02:00
parent 41aef56cba
commit 801e8e34cd
+18
View File
@@ -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);