Index: test/mjsunit/regress/regress-2855.js |
diff --git a/test/mjsunit/regress/regress-2855.js b/test/mjsunit/regress/regress-2855.js |
index ac721af73bf4c91ecc751fc31a3db91cf6942c93..24ec452d5994505c2db68476a0a946155f731bae 100644 |
--- a/test/mjsunit/regress/regress-2855.js |
+++ b/test/mjsunit/regress/regress-2855.js |
@@ -39,3 +39,19 @@ for (var i = 0; i < 4; ++i) { |
} |
assertEquals(expected, "" + foo("hello")); |
} |
+ |
+// Make sure we look up "valueOf" only once. |
+var count = 0; |
+var x = new String("foo"); |
+Object.defineProperty(x, "valueOf", |
+ { get: function() { |
+ count++; |
+ return function() { |
+ return 11; |
+ } |
+ } |
+ }); |
+for (var i = 0; i < 3; i++) { |
+ assertEquals("11", "" + x); |
+ assertEquals(i + 1, count); |
+} |