Closed Bug 226045 Opened 21 years ago Closed 21 years ago

RegExp toSource/toString return an invalid empty RE

Categories

(Rhino Graveyard :: Core, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: pschwartau, Assigned: igor)

Details

Attachments

(1 file)

SpiderMonkey recently changed the behavior of toString() and toSource()
when applied to a RegExp object with an empty pattern. Do we want 
Rhino to stay in synch?

This is the Rhino analogue of bug 225550 against SpiderMonkey.
The testcases for this are:

      mozilla/js/testsecma_2/RegExp/properties-001.js
      mozilla/js/testsjs1_2/regexp/toString.js


Here is a comparison of the current SpiderMonkey and Rhino:

RHINO:
[/] java org.mozilla.javascript.tools.shell.Main
Rhino 1.5 release 5 0000 00 00
js> (new RegExp).toString();
//
js> (new RegExp).toSource();
//


SPIDERMONKEY:
[//d/JS_TRUNK/mozilla/js/src/WINNT4.0_DBG.OBJ] ./js
js>
js> (new RegExp).toString();
/(?:)/
js> (new RegExp).toSource();
/(?:)/


The new approach lets eval() turn this string back into the empty regexp.
The old approach doesn't work, since "//" is a comment, not a regexp.
Oops, those tests are

      mozilla/js/tests/ecma_2/RegExp/properties-001.js
      mozilla/js/tests/js1_2/regexp/toString.js
I will fix it.
Assignee: nboyd → igor
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Verified FIXED.

The above testcases used to fail in both the compiled and interpreted
modes of Rhino. Now they pass in both -
Status: RESOLVED → VERIFIED
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: