OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return doo; | 107 return doo; |
108 } | 108 } |
109 | 109 |
110 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string"); | 110 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string"); |
111 | 111 |
112 function al() { | 112 function al() { |
113 assertEquals(Object(345), this); | 113 assertEquals(Object(345), this); |
114 return arguments.length + arguments[arguments.length - 1]; | 114 return arguments.length + arguments[arguments.length - 1]; |
115 } | 115 } |
116 | 116 |
117 for (var j = 1; j < 0x4000000; j <<= 1) { | 117 for (var j = 1; j < 0x400000; j <<= 1) { |
118 try { | 118 try { |
119 var a = %NormalizeElements([]); | 119 var a = %NormalizeElements([]); |
120 a.length = j; | 120 a.length = j; |
121 a[j - 1] = 42; | 121 a[j - 1] = 42; |
122 assertEquals(42 + j, al.apply(345, a)); | 122 assertEquals(42 + j, al.apply(345, a)); |
123 } catch (e) { | 123 } catch (e) { |
124 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1); | 124 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1); |
125 for (; j < 0x4000000; j <<= 1) { | 125 for (; j < 0x400000; j <<= 1) { |
126 var caught = false; | 126 var caught = false; |
127 try { | 127 try { |
128 a = %NormalizeElements([]); | 128 a = %NormalizeElements([]); |
129 a.length = j; | 129 a.length = j; |
130 a[j - 1] = 42; | 130 a[j - 1] = 42; |
131 al.apply(345, a); | 131 al.apply(345, a); |
132 assertUnreachable("Apply of array with length " + a.length + | 132 assertUnreachable("Apply of array with length " + a.length + |
133 " should have thrown"); | 133 " should have thrown"); |
134 } catch (e) { | 134 } catch (e) { |
135 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -
1); | 135 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -
1); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 "moreseper-prime"); | 194 "moreseper-prime"); |
195 | 195 |
196 delete(Array.prototype["1"]); | 196 delete(Array.prototype["1"]); |
197 | 197 |
198 // Check correct handling of non-array argument lists. | 198 // Check correct handling of non-array argument lists. |
199 assertSame(this, f0.apply(this, {}), "non-array-1"); | 199 assertSame(this, f0.apply(this, {}), "non-array-1"); |
200 assertSame(this, f0.apply(this, { length:1 }), "non-array-2"); | 200 assertSame(this, f0.apply(this, { length:1 }), "non-array-2"); |
201 assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3"); | 201 assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3"); |
202 assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4"); | 202 assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4"); |
203 assertEquals("foo", f1.apply(this, { length:1, 0:"foo" }), "non-array-5"); | 203 assertEquals("foo", f1.apply(this, { length:1, 0:"foo" }), "non-array-5"); |
OLD | NEW |