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

Side by Side Diff: test/mjsunit/mjsunit.js

Issue 88022: Add Array.prototype.reduce and .reduceRight. (Closed)
Patch Set: Created 11 years, 8 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 unified diff | Download patch
« test/mjsunit/array-reduce.js ('K') | « test/mjsunit/array-reduce.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 start = "Fail" + "ure (" + name_opt + "): "; 46 start = "Fail" + "ure (" + name_opt + "): ";
47 } else { 47 } else {
48 start = "Fail" + "ure:"; 48 start = "Fail" + "ure:";
49 } 49 }
50 throw new MjsUnitAssertionError(start + " expected <" + expected + "> found <" + found + ">"); 50 throw new MjsUnitAssertionError(start + " expected <" + expected + "> found <" + found + ">");
51 } 51 }
52 52
53 53
54 function deepEquals(a, b) { 54 function deepEquals(a, b) {
55 if (a == b) return true; 55 if (a == b) return true;
56 if (typeof a == "number" && typeof b == "number" && isNaN(a) && isNaN(b)) {
57 return true;
58 }
56 if ((typeof a) !== 'object' || (typeof b) !== 'object' || 59 if ((typeof a) !== 'object' || (typeof b) !== 'object' ||
57 (a === null) || (b === null)) 60 (a === null) || (b === null))
58 return false; 61 return false;
59 if (a.constructor === Array) { 62 if (a.constructor === Array) {
60 if (b.constructor !== Array) 63 if (b.constructor !== Array)
61 return false; 64 return false;
62 if (a.length != b.length) 65 if (a.length != b.length)
63 return false; 66 return false;
64 for (var i = 0; i < a.length; i++) { 67 for (var i = 0; i < a.length; i++) {
65 if (i in a) { 68 if (i in a) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 159
157 160
158 function assertUnreachable(name_opt) { 161 function assertUnreachable(name_opt) {
159 // Fix this when we ditch the old test runner. 162 // Fix this when we ditch the old test runner.
160 var message = "Fail" + "ure: unreachable" 163 var message = "Fail" + "ure: unreachable"
161 if (name_opt) { 164 if (name_opt) {
162 message += " - " + name_opt; 165 message += " - " + name_opt;
163 } 166 }
164 throw new MjsUnitAssertionError(message); 167 throw new MjsUnitAssertionError(message);
165 } 168 }
OLDNEW
« test/mjsunit/array-reduce.js ('K') | « test/mjsunit/array-reduce.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698