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 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 // When calling user-defined functions on strings, booleans or | 28 // When calling user-defined functions on strings, booleans or |
29 // numbers, we should create a wrapper object. | 29 // numbers, we should create a wrapper object. |
30 | 30 |
31 // When running the tests use loops to ensure that the call site moves through | 31 // When running the tests use loops to ensure that the call site moves through |
32 // the different IC states and that both the runtime system and the generated | 32 // the different IC states and that both the runtime system and the generated |
33 // IC code is tested. | 33 // IC code is tested. |
| 34 |
34 function RunTests() { | 35 function RunTests() { |
35 for (var i = 0; i < 10; i++) { | 36 for (var i = 0; i < 10; i++) { |
36 assertEquals('object', 'xxx'.TypeOfThis()); | 37 assertEquals('object', 'xxx'.TypeOfThis()); |
37 assertEquals('object', true.TypeOfThis(2,3)); | 38 assertEquals('object', true.TypeOfThis(2,3)); |
38 assertEquals('object', false.TypeOfThis()); | 39 assertEquals('object', false.TypeOfThis()); |
39 assertEquals('object', (42).TypeOfThis()); | 40 assertEquals('object', (42).TypeOfThis()); |
40 assertEquals('object', (3.14).TypeOfThis()); | 41 assertEquals('object', (3.14).TypeOfThis()); |
41 } | 42 } |
42 | 43 |
43 for (var i = 0; i < 10; i++) { | 44 for (var i = 0; i < 10; i++) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 assertEquals('object', TypeOfThis.apply(42, [])); | 156 assertEquals('object', TypeOfThis.apply(42, [])); |
156 assertEquals('object', TypeOfThis.apply(3.14, [])); | 157 assertEquals('object', TypeOfThis.apply(3.14, [])); |
157 | 158 |
158 // According to ES3 15.3.4.3 the this value passed to Function.prototyle.call | 159 // According to ES3 15.3.4.3 the this value passed to Function.prototyle.call |
159 // should wrapped. According to ES5 it should not. | 160 // should wrapped. According to ES5 it should not. |
160 assertEquals('object', TypeOfThis.call('xxx')); | 161 assertEquals('object', TypeOfThis.call('xxx')); |
161 assertEquals('object', TypeOfThis.call(true)); | 162 assertEquals('object', TypeOfThis.call(true)); |
162 assertEquals('object', TypeOfThis.call(false)); | 163 assertEquals('object', TypeOfThis.call(false)); |
163 assertEquals('object', TypeOfThis.call(42)); | 164 assertEquals('object', TypeOfThis.call(42)); |
164 assertEquals('object', TypeOfThis.call(3.14)); | 165 assertEquals('object', TypeOfThis.call(3.14)); |
OLD | NEW |