Revision: 4551
Author:   metaweta
Date:     Wed Jul 13 15:50:29 2011
Log:      Fixes failing ArrayIndexOptimizationTest
http://codereview.appspot.com/4700046

In the latest version of Rhino, declaring a variable named
'undefined' throws an error.  I'm not sure how I was able to submit
the updated rhino without this test failing, but this fixes it.

R=jasvir, mikesamuel

http://code.google.com/p/google-caja/source/detail?r=4551

Modified:
 /trunk/src/com/google/caja/es53.js
/trunk/tests/com/google/caja/parser/quasiliteral/opt/array-opt-operator-test.js

=======================================
--- /trunk/src/com/google/caja/es53.js  Tue Jul 12 09:20:13 2011
+++ /trunk/src/com/google/caja/es53.js  Wed Jul 13 15:50:29 2011
@@ -1112,8 +1112,8 @@
   }

   var endsWith__ = /__$/;
-  var endsWith_e___ = /(.*?)_e___$/;
-  var endsWith_v___ = /(.*?)_v___$/;
+  var endsWith_e___ = /([\s\S]*)_e___$/;
+  var endsWith_v___ = /([\s\S]*)_v___$/;
   var startsWithNUM___ = /^NUM___/;

   function assertValidPropertyName(P) {
@@ -3556,11 +3556,14 @@
     }
     obj.ne___ = obj;
     for (var i in obj) {
-      if (!guestHasOwnProperty(obj,i)) { continue; }
+      if (!obj.hasOwnProperty(i)) { continue; }
       if (isNumericName(i)) { continue; }
-      obj[i + '_c___'] = false;
-      obj[i + '_gw___'] = false;
-      obj[i + '_w___'] = false;
+      var m = i.match(endsWith_v___);
+      if (!m) { continue; }
+      var j = m[1];
+      obj[j + '_c___'] = false;
+      obj[j + '_gw___'] = false;
+      obj[j + '_w___'] = false;
     }
     if (!obj.hasNumerics___()) {
       obj.NUM____v___ = obj;
=======================================
--- /trunk/tests/com/google/caja/parser/quasiliteral/opt/array-opt-operator-test.js Tue Oct 26 11:26:41 2010 +++ /trunk/tests/com/google/caja/parser/quasiliteral/opt/array-opt-operator-test.js Wed Jul 13 15:50:29 2011
@@ -5,7 +5,6 @@
  * @author [email protected]
  */

-var undefined;
 var nullValue;
 var zero;
 var negOne;

Reply via email to