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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 x += x; // 2^10 | 128 x += x; // 2^10 |
129 x += x; | 129 x += x; |
130 x += x; | 130 x += x; |
131 var xl = x.length; | 131 var xl = x.length; |
132 var cache = []; | 132 var cache = []; |
133 for (var i = 0; i < 10000; i++) { | 133 for (var i = 0; i < 10000; i++) { |
134 var z = x.substring(i % xl); | 134 var z = x.substring(i % xl); |
135 assertEquals(xl - (i % xl), z.length); | 135 assertEquals(xl - (i % xl), z.length); |
136 cache.push(z); | 136 cache.push(z); |
137 } | 137 } |
| 138 |
| 139 // Substring of substring. |
| 140 var cache = []; |
| 141 var last = x; |
| 142 var offset = 0; |
| 143 for (var i = 0; i < 64; i++) { |
| 144 var z = last.substring(i); |
| 145 last = z; |
| 146 cache.push(z); |
| 147 offset += i; |
| 148 } |
| 149 for (var i = 63; i >= 0; i--) { |
| 150 var z = cache.pop(); |
| 151 assertTrue(/\u2028123456789ABCDEF/.test(z)); |
| 152 assertEquals(xl - offset, z.length); |
| 153 offset -= i; |
| 154 } |
OLD | NEW |