> From: Brendan Eich <bren...@mozilla.com>
> Subject: Re: [JS-internals] additional test for 15.10.6.2, 
> RegExp.prototype.exec
> Date: 27 June 2013 0:16:49 GMT+02:00
> To: Paul Ruizendaal <p...@planet.nl>
> 
> Please resend to es-discuss. At least two browsers agree on each side of the 
> fence, so this isn't just a mozilla.dev.tech.js-engine.internal issue.
> 
> /be
> 
> Paul Ruizendaal wrote:
>> The Spidermonkey test suite contains the following test (in file 
>> ecma_5/RegExp/exec.js):
>> 
>> r = /abc/;
>> r.lastIndex = -17;
>> res = r.exec("cdefg");
>> assertEq(res, null);
>> assertEq(r.lastIndex, -17);
>> 
>> In my understanding this test is wrong, lastIndex should be 0 due to step 
>> 9.a.(i). Safari and Firefox report -17, Chrome and IE report 0. I guess it 
>> is a tricky part of the spec as most real world implementations will move 
>> the iteration of step 9 into the [[Match]] routine as to enable first 
>> character optimizations and alike. The correct behavior is not covered in 
>> test262. Recommend to add the following test:
>> 
>> /*
>>  * @es5id 15.10.6.2 (step 9.a.i)
>>  * @description If the pattern does not match, lastIndex is always set to 0, 
>> even if the 'global' flag is false.
>>  */
>> function testCase()
>> {
>>   var r = /abc/;
>>   r.lastIndex = -17;
>>   res = r.exec("defg");
>>   return r.lastIndex===0;
>> }
>> 
>> Note that the original Spidermonkey test is in the public domain, according 
>> to the file header. This post is also placed in the public domain.
>> 
>> Paul
>> 
>> _______________________________________________
>> dev-tech-js-engine-internals mailing list
>> dev-tech-js-engine-intern...@lists.mozilla.org
>> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to