Index: test/mjsunit/regress/regress-1365.js |
diff --git a/test/mjsunit/regress/regress-1170.js b/test/mjsunit/regress/regress-1365.js |
similarity index 52% |
copy from test/mjsunit/regress/regress-1170.js |
copy to test/mjsunit/regress/regress-1365.js |
index 8a5a9cfb19b7f20247ce4a43819c5ebbdb5ff67a..3366fe1998af52ac18d7c0b87e649f0206741632 100644 |
--- a/test/mjsunit/regress/regress-1170.js |
+++ b/test/mjsunit/regress/regress-1365.js |
@@ -25,42 +25,54 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-var setter_value = 0; |
+// See: http://code.google.com/p/v8/issues/detail?id=1365 |
-__proto__.__defineSetter__("a", function(v) { setter_value = v; }); |
-eval("var a = 1"); |
-assertEquals(1, setter_value); |
-assertFalse(hasOwnProperty("a")); |
+// Check that builtin methods are passed undefined as the receiver |
+// when called as functions through variables. |
-eval("with({}) { eval('var a = 2') }"); |
-assertEquals(2, setter_value); |
-assertFalse(hasOwnProperty("a")); |
+// Flags: --allow-natives-syntax |
-// Function declarations are treated specially to match Safari. We do |
-// not call setters for them. |
-eval("function a() {}"); |
-assertTrue(hasOwnProperty("a")); |
+// Global variable. |
+var valueOf = Object.prototype.valueOf; |
+var hasOwnProperty = Object.prototype.hasOwnProperty; |
+ |
+function CheckExceptionCallGlobal() { |
+ var exception = false; |
+ try { valueOf(); } catch(e) { exception = true; } |
+ assertTrue(exception); |
Lasse Reichstein
2011/05/26 08:26:55
Test for thrown exceptions by either:
assertThro
Mads Ager (chromium)
2011/05/26 10:14:07
Done.
|
+ exception = false; |
+ try { hasOwnProperty(); } catch(e) { exception = true; } |
+ assertTrue(exception); |
-__proto__.__defineSetter__("b", function(v) { assertUnreachable(); }); |
-try { |
- eval("const b = 23"); |
- assertUnreachable(); |
-} catch(e) { |
- assertTrue(/TypeError/.test(e)); |
-} |
-try { |
- eval("with({}) { eval('const b = 23') }"); |
- assertUnreachable(); |
-} catch(e) { |
- assertTrue(/TypeError/.test(e)); |
} |
-__proto__.__defineSetter__("c", function(v) { throw 42; }); |
-try { |
- eval("var c = 1"); |
- assertUnreachable(); |
-} catch(e) { |
- assertEquals(42, e); |
- assertFalse(hasOwnProperty("c")); |
+assertEquals(Object.prototype, Object.prototype.valueOf()); |
+CheckExceptionCallGlobal(); |
+ |
+%OptimizeFunctionOnNextCall(Object.prototype.valueOf); |
+Object.prototype.valueOf(); |
+ |
+assertEquals(Object.prototype, Object.prototype.valueOf()); |
+CheckExceptionCallGlobal(); |
+ |
+function CheckExceptionCallLocal() { |
+ var valueOf = Object.prototype.valueOf; |
+ var hasOwnProperty = Object.prototype.hasOwnProperty |
+ |
+ var exception = false; |
+ try { valueOf(); } catch(e) { exception = true; } |
+ assertTrue(exception); |
+ |
+ var exception = false; |
+ try { hasOwnProperty(); } catch(e) { exception = true; } |
+ assertTrue(exception); |
} |
+CheckExceptionCallLocal(); |
+function CheckExceptionCallParameter(f) { |
+ var exception = false; |
+ try { f(); } catch(e) { exception = true; } |
+ assertTrue(exception); |
+} |
+CheckExceptionCallParameter(Object.prototype.valueOf); |
+CheckExceptionCallParameter(Object.prototype.hasOwnProperty); |