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

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

Issue 6087011: Draft of ES5 fix to Function.prototype.call and apply (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 11 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 | « src/x64/builtins-x64.cc ('k') | test/mjsunit/arguments-apply.js » ('j') | 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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 function f0() { 28 function f0() {
29 return this; 29 return this;
30 } 30 }
31 31
32 function f1(a) { 32 function f1(a) {
33 return a; 33 return a;
34 } 34 }
35 35
36 assertTrue(this === f0.apply(), "1-0"); 36 assertTrue(undefined === f0.apply(), "1-0");
37 37
38 assertTrue(this === f0.apply(this), "2a"); 38 assertTrue(this === f0.apply(this), "2a");
39 assertTrue(this === f0.apply(this, new Array(1)), "2b"); 39 assertTrue(this === f0.apply(this, new Array(1)), "2b");
40 assertTrue(this === f0.apply(this, new Array(2)), "2c"); 40 assertTrue(this === f0.apply(this, new Array(2)), "2c");
41 assertTrue(this === f0.apply(this, new Array(4242)), "2d"); 41 assertTrue(this === f0.apply(this, new Array(4242)), "2d");
42 42
43 assertTrue(this === f0.apply(null), "3a"); 43 assertTrue(null === f0.apply(null), "3a");
44 assertTrue(this === f0.apply(null, new Array(1)), "3b"); 44 assertTrue(null === f0.apply(null, new Array(1)), "3b");
45 assertTrue(this === f0.apply(null, new Array(2)), "3c"); 45 assertTrue(null === f0.apply(null, new Array(2)), "3c");
46 assertTrue(this === f0.apply(this, new Array(4242)), "3d"); 46 assertTrue(this === f0.apply(this, new Array(4242)), "3d");
47 47
48 assertTrue(this === f0.apply(void 0), "4a"); 48 assertTrue(undefined === f0.apply(void 0), "4a");
49 assertTrue(this === f0.apply(void 0, new Array(1)), "4b"); 49 assertTrue(undefined === f0.apply(void 0, new Array(1)), "4b");
50 assertTrue(this === f0.apply(void 0, new Array(2)), "4c"); 50 assertTrue(undefined === f0.apply(void 0, new Array(2)), "4c");
51 51
52 assertTrue(void 0 === f1.apply(), "1-1"); 52 assertTrue(void 0 === f1.apply(), "1-1");
53 53
54 assertTrue(void 0 === f1.apply(this), "5a"); 54 assertTrue(void 0 === f1.apply(this), "5a");
55 assertTrue(void 0 === f1.apply(this, new Array(1)), "5b"); 55 assertTrue(void 0 === f1.apply(this, new Array(1)), "5b");
56 assertTrue(void 0 === f1.apply(this, new Array(2)), "5c"); 56 assertTrue(void 0 === f1.apply(this, new Array(2)), "5c");
57 assertTrue(void 0 === f1.apply(this, new Array(4242)), "5d"); 57 assertTrue(void 0 === f1.apply(this, new Array(4242)), "5d");
58 assertTrue(42 === f1.apply(this, new Array(42, 43)), "5e"); 58 assertTrue(42 === f1.apply(this, new Array(42, 43)), "5e");
59 assertEquals("foo", f1.apply(this, new Array("foo", "bar", "baz", "bo")), "5f"); 59 assertEquals("foo", f1.apply(this, new Array("foo", "bar", "baz", "bo")), "5f");
60 60
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 "morseper4"); 183 "morseper4");
184 184
185 primes[0] = ""; 185 primes[0] = "";
186 primes[1] = holey; 186 primes[1] = holey;
187 assertThrows("String.prototype.concat.apply.apply('foo', primes)"); 187 assertThrows("String.prototype.concat.apply.apply('foo', primes)");
188 assertEquals("morseper", 188 assertEquals("morseper",
189 String.prototype.concat.apply.apply(String.prototype.concat, primes), 189 String.prototype.concat.apply.apply(String.prototype.concat, primes),
190 "moreseper-prime"); 190 "moreseper-prime");
191 191
192 delete(Array.prototype["1"]); 192 delete(Array.prototype["1"]);
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/mjsunit/arguments-apply.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698