Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Unified Diff: test/mjsunit/regress/regress-1436.js

Issue 7044054: Fix Array.prototype.{reduce,reduceRight} to pass undefined as receiver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Just fix the issue. :-) Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-1436.js
diff --git a/src/preparse-data-format.h b/test/mjsunit/regress/regress-1436.js
similarity index 58%
copy from src/preparse-data-format.h
copy to test/mjsunit/regress/regress-1436.js
index 64c4f18169ac353447f3c44002469c5e0640ca84..5e26e6d846bd2d4f326bf2a264fa614e6674120d 100644
--- a/src/preparse-data-format.h
+++ b/test/mjsunit/regress/regress-1436.js
@@ -1,4 +1,4 @@
-// Copyright 2010 the V8 project authors. All rights reserved.
+// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,38 +25,30 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef V8_PREPARSE_DATA_FORMAT_H_
-#define V8_PREPARSE_DATA_FORMAT_H_
-
-namespace v8 {
-namespace internal {
-
-// Generic and general data used by preparse data recorders and readers.
-
-struct PreparseDataConstants {
- public:
- // Layout and constants of the preparse data exchange format.
- static const unsigned kMagicNumber = 0xBadDead;
- static const unsigned kCurrentVersion = 6;
-
- static const int kMagicOffset = 0;
- static const int kVersionOffset = 1;
- static const int kHasErrorOffset = 2;
- static const int kFunctionsSizeOffset = 3;
- static const int kSymbolCountOffset = 4;
- static const int kSizeOffset = 5;
- static const int kHeaderSize = 6;
-
- // If encoding a message, the following positions are fixed.
- static const int kMessageStartPos = 0;
- static const int kMessageEndPos = 1;
- static const int kMessageArgCountPos = 2;
- static const int kMessageTextPos = 3;
-
- static const unsigned char kNumberTerminator = 0x80u;
-};
-
-
-} } // namespace v8::internal.
-
-#endif // V8_PREPARSE_DATA_FORMAT_H_
+// Check that reduce and reduceRight call the callback function with
+// undefined as the receiver (which for non-strict functions is
+// transformed to the global object).
+
+// Check receiver for reduce and reduceRight.
+
+var global = this;
+function non_strict(){ assertEquals(global, this); }
+function strict(){ "use strict"; assertEquals(void 0, this); }
+
+[2, 3].reduce(non_strict);
+[2, 3].reduceRight(non_strict);
+[2, 3].reduce(strict);
Lasse Reichstein 2011/06/09 08:57:02 Group by function called, like below (i.e., both r
Mads Ager (chromium) 2011/06/09 09:05:03 Done.
+[2, 3].reduceRight(strict);
+
+
+// Check the receiver for callbacks in other array methods.
+[2, 3].filter(non_strict);
+[2, 3].filter(strict);
+[2, 3].forEach(non_strict);
+[2, 3].forEach(strict);
+[2, 3].some(non_strict);
+[2, 3].some(strict);
+[2, 3].every(non_strict);
+[2, 3].every(strict);
+[2, 3].map(non_strict);
+[2, 3].map(strict);
Lasse Reichstein 2011/06/09 08:57:02 How about putting them in alphabetic order. Matbe
Mads Ager (chromium) 2011/06/09 09:05:03 Done.
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698