OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return ReturnReceiver.apply(receiver, arguments); | 73 return ReturnReceiver.apply(receiver, arguments); |
74 } | 74 } |
75 | 75 |
76 assertEquals(42, NonObjectReceiver(42)); | 76 assertEquals(42, NonObjectReceiver(42)); |
77 assertEquals("object", typeof NonObjectReceiver(42)); | 77 assertEquals("object", typeof NonObjectReceiver(42)); |
78 assertTrue(NonObjectReceiver(42) instanceof Number); | 78 assertTrue(NonObjectReceiver(42) instanceof Number); |
79 assertTrue(this === NonObjectReceiver(null)); | 79 assertTrue(this === NonObjectReceiver(null)); |
80 assertTrue(this === NonObjectReceiver(void 0)); | 80 assertTrue(this === NonObjectReceiver(void 0)); |
81 | 81 |
82 | 82 |
| 83 function FunctionReceiver() { |
| 84 return ReturnReceiver.apply(Object, arguments); |
| 85 } |
| 86 |
| 87 assertTrue(Object === FunctionReceiver()); |
| 88 |
| 89 |
83 function ShadowApply() { | 90 function ShadowApply() { |
84 function f() { return 42; } | 91 function f() { return 42; } |
85 f.apply = function() { return 87; } | 92 f.apply = function() { return 87; } |
86 return f.apply(this, arguments); | 93 return f.apply(this, arguments); |
87 } | 94 } |
88 | 95 |
89 assertEquals(87, ShadowApply()); | 96 assertEquals(87, ShadowApply()); |
90 assertEquals(87, ShadowApply(1)); | 97 assertEquals(87, ShadowApply(1)); |
91 assertEquals(87, ShadowApply(1, 2)); | 98 assertEquals(87, ShadowApply(1, 2)); |
92 | 99 |
(...skipping 25 matching lines...) Expand all Loading... |
118 | 125 |
119 assertEquals(0, ShadowArgumentsWithConstant().length); | 126 assertEquals(0, ShadowArgumentsWithConstant().length); |
120 assertEquals(0, ShadowArgumentsWithConstant(1).length); | 127 assertEquals(0, ShadowArgumentsWithConstant(1).length); |
121 assertEquals(0, ShadowArgumentsWithConstant(1, 2).length); | 128 assertEquals(0, ShadowArgumentsWithConstant(1, 2).length); |
122 | 129 |
123 | 130 |
124 // Make sure we can deal with unfolding lots of arguments on the | 131 // Make sure we can deal with unfolding lots of arguments on the |
125 // stack even in the presence of the apply optimizations. | 132 // stack even in the presence of the apply optimizations. |
126 var array = new Array(2048); | 133 var array = new Array(2048); |
127 assertEquals(2048, Global.apply(this, array).length); | 134 assertEquals(2048, Global.apply(this, array).length); |
OLD | NEW |