Reviewers: Rico, sandholm,

Description:
Remove special-casing of calls to RegExp test and exec methods with no argument.


Matches new JSC behavior. Fix issue 75740.


BUG=75740
TEST=mjsunit/regexp-static

Please review this at http://codereview.chromium.org/6677020/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/regexp.js
  M test/mjsunit/regexp-static.js
  M test/mozilla/mozilla.status
  M test/sputnik/sputnik.status


Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index f68dee6135471f1bc2e909c524e183a6a8922497..4ad9b3b94e807fd40ae26d9a091b61fb42b096ba 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -165,13 +165,6 @@ function RegExpExec(string) {
                         ['RegExp.prototype.exec', this]);
   }

-  if (%_ArgumentsLength() === 0) {
-    var regExpInput = LAST_INPUT(lastMatchInfo);
-    if (IS_UNDEFINED(regExpInput)) {
-      throw MakeError('no_input_to_regexp', [this]);
-    }
-    string = regExpInput;
-  }
   string = TO_STRING_INLINE(string);
   var lastIndex = this.lastIndex;

@@ -220,14 +213,6 @@ function RegExpTest(string) {
     throw MakeTypeError('incompatible_method_receiver',
                         ['RegExp.prototype.test', this]);
   }
-  if (%_ArgumentsLength() == 0) {
-    var regExpInput = LAST_INPUT(lastMatchInfo);
-    if (IS_UNDEFINED(regExpInput)) {
-      throw MakeError('no_input_to_regexp', [this]);
-    }
-    string = regExpInput;
-  }
-
   string = TO_STRING_INLINE(string);

   var lastIndex = this.lastIndex;
Index: test/mjsunit/regexp-static.js
diff --git a/test/mjsunit/regexp-static.js b/test/mjsunit/regexp-static.js
index 9e73f3d6ffaa2819cb02a56531c169bb550e17f8..43cad92816c5680dc4df45fba39aeae3ea9ae588 100644
--- a/test/mjsunit/regexp-static.js
+++ b/test/mjsunit/regexp-static.js
@@ -25,18 +25,6 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-// Test that we throw exceptions when calling test and exec with no
-// input.  This is not part of the spec, but we do it for
-// compatibility with JSC.
-assertThrows("/a/.test()");
-assertThrows("/a/.exec()");
-
-// Test that we do not throw exceptions once the static RegExp.input
-// field has been set.
-RegExp.input = "a";
-assertDoesNotThrow("/a/.test()");
-assertDoesNotThrow("/a/.exec()");
-
 // Test the (deprecated as of JS 1.5) properties of the RegExp function.
 var re = /((\d+)\.(\d+))/;
 var s = 'abc123.456def';
@@ -165,3 +153,8 @@ assertTrue(typeof RegExp.input == typeof String(), "RegExp.input coerces values var foo = "lsdfj sldkfj sdklfj læsdfjl sdkfjlsdk fjsdl fjsdljskdj flsj flsdkj flskd regexp: /foobar/\nldkfj sdlkfj sdkl"; assertTrue(/^([a-z]+): (.*)/.test(foo.substring(foo.indexOf("regexp:"))), "regexp: setup");
 assertEquals("regexp", RegExp.$1, "RegExp.$1");
+
+
+// Check that calling with no argument is the same as calling with undefined.
+assertTrue(/^undefined$/.test());
+assertEquals(["undefined"], /^undefined$/.exec());
\ No newline at end of file
Index: test/mozilla/mozilla.status
diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status
index 3b6a524c26898bacc141ef754469d8a6999eea8a..676b51c58c5518d0fe48c3e3a6afc843ab99a092 100644
--- a/test/mozilla/mozilla.status
+++ b/test/mozilla/mozilla.status
@@ -294,6 +294,11 @@ js1_2/regexp/RegExp_multiline_as_array: FAIL_OK
 js1_2/regexp/beginLine: FAIL_OK
 js1_2/regexp/endLine: FAIL_OK

+# We no longer let calls to test and exec with no argument implicitly
+# use the previous input.
+mozilla/js1_2/regexp/RegExp_input: FAIL_OK
+mozilla/js1_2/regexp/RegExp_input_as_array: FAIL_OK
+

 # To be compatible with safari typeof a regexp yields 'function';
 # in firefox it yields 'object'.
Index: test/sputnik/sputnik.status
diff --git a/test/sputnik/sputnik.status b/test/sputnik/sputnik.status
index 6da87eac95acb69806dafab2271e5cf092412055..b70cff8a17b40ca882e2f6bccc7780e487916535 100644
--- a/test/sputnik/sputnik.status
+++ b/test/sputnik/sputnik.status
@@ -45,11 +45,6 @@ S15.8.2.16_A7: PASS || FAIL_OK
 S15.8.2.18_A7: PASS || FAIL_OK
 S15.8.2.13_A23: PASS || FAIL_OK

-# We allow calls to regexp exec() with no arguments to fail for
-# compatibility reasons.
-S15.10.6.2_A1_T16: FAIL_OK
-S15.10.6.3_A1_T16: FAIL_OK
-
 # We allow regexps to be called as functions for compatibility reasons.
 S15.10.7_A1_T1: FAIL_OK
 S15.10.7_A1_T2: FAIL_OK


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to