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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 assertEquals(-1, Array.prototype.indexOf.call(dense_object, 87)); | 104 assertEquals(-1, Array.prototype.indexOf.call(dense_object, 87)); |
105 | 105 |
106 assertEquals(0, Array.prototype.indexOf.call(sparse_object, 42)); | 106 assertEquals(0, Array.prototype.indexOf.call(sparse_object, 42)); |
107 assertEquals(100000, Array.prototype.indexOf.call(sparse_object, 37)); | 107 assertEquals(100000, Array.prototype.indexOf.call(sparse_object, 37)); |
108 assertEquals(-1, Array.prototype.indexOf.call(sparse_object, 87)); | 108 assertEquals(-1, Array.prototype.indexOf.call(sparse_object, 87)); |
109 | 109 |
110 assertEquals(10, Array.prototype.indexOf.call(funky_object, 42)); | 110 assertEquals(10, Array.prototype.indexOf.call(funky_object, 42)); |
111 assertEquals(-1, Array.prototype.indexOf.call(funky_object, 42, 15)); | 111 assertEquals(-1, Array.prototype.indexOf.call(funky_object, 42, 15)); |
112 assertEquals(-1, Array.prototype.indexOf.call(funky_object, 37)); | 112 assertEquals(-1, Array.prototype.indexOf.call(funky_object, 37)); |
113 | 113 |
114 assertEquals(-1, Array.prototype.indexOf.call(infinite_object, 42)); | 114 assertEquals(10, Array.prototype.indexOf.call(infinite_object, 42)); |
115 | 115 |
116 // ---------------------------------------------------------------------- | 116 // ---------------------------------------------------------------------- |
117 // Array.prototype.lastIndexOf. | 117 // Array.prototype.lastIndexOf. |
118 // ---------------------------------------------------------------------- | 118 // ---------------------------------------------------------------------- |
119 | 119 |
120 // Negative cases. | 120 // Negative cases. |
121 assertEquals(-1, [].lastIndexOf(1)); | 121 assertEquals(-1, [].lastIndexOf(1)); |
122 assertEquals(-1, array.lastIndexOf(1, -17)); | 122 assertEquals(-1, array.lastIndexOf(1, -17)); |
123 | 123 |
124 assertEquals(9, array.lastIndexOf(1)); | 124 assertEquals(9, array.lastIndexOf(1)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 assertEquals(-1, Array.prototype.lastIndexOf.call(dense_object, 87)); | 176 assertEquals(-1, Array.prototype.lastIndexOf.call(dense_object, 87)); |
177 | 177 |
178 assertEquals(0, Array.prototype.lastIndexOf.call(sparse_object, 42)); | 178 assertEquals(0, Array.prototype.lastIndexOf.call(sparse_object, 42)); |
179 assertEquals(100000, Array.prototype.lastIndexOf.call(sparse_object, 37)); | 179 assertEquals(100000, Array.prototype.lastIndexOf.call(sparse_object, 37)); |
180 assertEquals(-1, Array.prototype.lastIndexOf.call(sparse_object, 87)); | 180 assertEquals(-1, Array.prototype.lastIndexOf.call(sparse_object, 87)); |
181 | 181 |
182 assertEquals(10, Array.prototype.lastIndexOf.call(funky_object, 42, 15)); | 182 assertEquals(10, Array.prototype.lastIndexOf.call(funky_object, 42, 15)); |
183 assertEquals(10, Array.prototype.lastIndexOf.call(funky_object, 42)); | 183 assertEquals(10, Array.prototype.lastIndexOf.call(funky_object, 42)); |
184 assertEquals(-1, Array.prototype.lastIndexOf.call(funky_object, 37)); | 184 assertEquals(-1, Array.prototype.lastIndexOf.call(funky_object, 37)); |
185 | 185 |
186 assertEquals(-1, Array.prototype.lastIndexOf.call(infinite_object, 42)); | 186 // This call would take too long because it would search backwards from 2**53-1 |
| 187 // assertEquals(-1, Array.prototype.lastIndexOf.call(infinite_object, 42)); |
OLD | NEW |