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

Side by Side Diff: test/mjsunit/array-iteration.js

Issue 10827295: Fix array-iteration test case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 22 matching lines...) Expand all
33 // 33 //
34 // for an explanation of each of the functions. 34 // for an explanation of each of the functions.
35 35
36 // 36 //
37 // Array.prototype.filter 37 // Array.prototype.filter
38 // 38 //
39 (function() { 39 (function() {
40 // Simple use. 40 // Simple use.
41 var a = [0,1]; 41 var a = [0,1];
42 assertArrayEquals([0], a.filter(function(n) { return n == 0; })); 42 assertArrayEquals([0], a.filter(function(n) { return n == 0; }));
43 assertArrayEquals(a, a); 43 assertArrayEquals([0,1], a);
44 44
45 // Use specified object as this object when calling the function. 45 // Use specified object as this object when calling the function.
46 var o = { value: 42 } 46 var o = { value: 42 }
47 a = [1,42,3,42,4]; 47 a = [1,42,3,42,4];
48 assertArrayEquals([42,42], a.filter(function(n) { return this.value == n }, o) ) 48 assertArrayEquals([42,42], a.filter(function(n) { return this.value == n }, o) )
49 49
50 // Modify original array. 50 // Modify original array.
51 a = [1,42,3,42,4]; 51 a = [1,42,3,42,4];
52 assertArrayEquals([42,42], a.filter(function(n, index, array) { array[index] = 43; return 42 == n; })); 52 assertArrayEquals([42,42], a.filter(function(n, index, array) { array[index] = 43; return 42 == n; }));
53 assertArrayEquals([43,43,43,43,43], a); 53 assertArrayEquals([43,43,43,43,43], a);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 a = new Array(20); 219 a = new Array(20);
220 var count = 0; 220 var count = 0;
221 a[2] = 42; 221 a[2] = 42;
222 a[10] = 2; 222 a[10] = 2;
223 a[15] = 42; 223 a[15] = 42;
224 assertTrue(a.some(function(n) { count++; return n == 2; })); 224 assertTrue(a.some(function(n) { count++; return n == 2; }));
225 assertEquals(2, count); 225 assertEquals(2, count);
226 226
227 })(); 227 })();
228 228
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698