Author: [EMAIL PROTECTED]
Date: Wed Dec  3 04:47:21 2008
New Revision: 907

Removed:
    branches/bleeding_edge/test/mjsunit/nested-repetition-count-overflow.js
Modified:
    branches/bleeding_edge/src/messages.js
    branches/bleeding_edge/src/regexp-delay.js
    branches/bleeding_edge/test/mjsunit/mjsunit.js
    branches/bleeding_edge/test/mjsunit/regexp-static.js

Log:
Follow jsc in throwing an exception when using test or exec on a
regexp with no input.

Fixed problem with assertThrows.

Deleted test that tests arbitrary limits on the sizes of regular
expressions.
Review URL: http://codereview.chromium.org/13088

Modified: branches/bleeding_edge/src/messages.js
==============================================================================
--- branches/bleeding_edge/src/messages.js      (original)
+++ branches/bleeding_edge/src/messages.js      Wed Dec  3 04:47:21 2008
@@ -112,6 +112,7 @@
    illegal_continue:             "Illegal continue statement",
    illegal_return:               "Illegal return statement",
    error_loading_debugger:       "Error loading debugger %0",
+  no_input_to_regexp:           "No input to %0",
  };



Modified: branches/bleeding_edge/src/regexp-delay.js
==============================================================================
--- branches/bleeding_edge/src/regexp-delay.js  (original)
+++ branches/bleeding_edge/src/regexp-delay.js  Wed Dec  3 04:47:21 2008
@@ -163,6 +163,9 @@

  function RegExpExec(string) {
    if (%_ArgumentsLength() == 0) {
+    if (IS_UNDEFINED(regExpInput)) {
+      throw MakeError('no_input_to_regexp', [this]);
+    }
      string = regExpInput;
    }
    var s = ToString(string);
@@ -283,7 +286,7 @@
  // the last successful match.
  var regExpCaptures = [0, 0];
  var regExpSubject = '';
-var regExpInput = "";
+var regExpInput;

  // -------------------------------------------------------------------

@@ -308,13 +311,11 @@
    %FunctionSetLength($RegExp.prototype.compile, 1);

    // The properties input, $input, and $_ are aliases for each other.   
When this
-  // value is set in SpiderMonkey, the value it is set to is coerced to a
-  // string.  We mimic that behavior with a slight difference: in  
SpiderMonkey
-  // the value of the expression 'RegExp.input = null' (for instance) is  
the
-  // string "null" (ie, the value after coercion), while in V8 it is the  
value
-  // null (ie, the value before coercion).
+  // value is set the value it is set to is coerced to a string.
    // Getter and setter for the input.
-  function RegExpGetInput() { return regExpInput; }
+  function RegExpGetInput() {
+    return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
+  }
    function RegExpSetInput(string) { regExpInput = ToString(string); }

    %DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE);

Modified: branches/bleeding_edge/test/mjsunit/mjsunit.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/mjsunit.js      (original)
+++ branches/bleeding_edge/test/mjsunit/mjsunit.js      Wed Dec  3 04:47:21 2008
@@ -90,12 +90,14 @@


  function assertThrows(code) {
+  var threwException = true;
    try {
      eval(code);
-    assertTrue(false, "did not throw exception");
+    threwException = false;
    } catch (e) {
      // Do nothing.
    }
+  if (!threwException) assertTrue(false, "did not throw exception");
  }



Modified: branches/bleeding_edge/test/mjsunit/regexp-static.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/regexp-static.js        (original)
+++ branches/bleeding_edge/test/mjsunit/regexp-static.js        Wed Dec  3  
04:47:21 2008
@@ -25,6 +25,18 @@
  // (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';

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

Reply via email to