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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 assertEquals(s.substring(s.length - 1), s.substr(-1)); | 48 assertEquals(s.substring(s.length - 1), s.substr(-1)); |
49 assertEquals(s.substring(s.length - 1), s.substr(-1.2)); | 49 assertEquals(s.substring(s.length - 1), s.substr(-1.2)); |
50 assertEquals(s.substring(s.length - 1), s.substr(-1.7)); | 50 assertEquals(s.substring(s.length - 1), s.substr(-1.7)); |
51 assertEquals(s.substring(s.length - 2), s.substr(-2)); | 51 assertEquals(s.substring(s.length - 2), s.substr(-2)); |
52 assertEquals(s.substring(s.length - 2), s.substr(-2.3)); | 52 assertEquals(s.substring(s.length - 2), s.substr(-2.3)); |
53 assertEquals(s.substring(s.length - 2, s.length - 1), s.substr(-2, 1)); | 53 assertEquals(s.substring(s.length - 2, s.length - 1), s.substr(-2, 1)); |
54 assertEquals(s, s.substr(-100)); | 54 assertEquals(s, s.substr(-100)); |
55 assertEquals('abc', s.substr(-100, 3)); | 55 assertEquals('abc', s.substr(-100, 3)); |
56 assertEquals(s1, s.substr(-s.length + 1)); | 56 assertEquals(s1, s.substr(-s.length + 1)); |
57 | 57 |
58 // assertEquals('', s.substr(0, void 0)); // smjs and rhino | 58 // assertEquals('', s.substr(0, void 0)); // smjs and rhino |
59 assertEquals('abcdefghijklmn', s.substr(0, void 0)); // kjs and v8 | 59 assertEquals('abcdefghijklmn', s.substr(0, void 0)); // kjs and v8 |
60 assertEquals('', s.substr(0, null)); | 60 assertEquals('', s.substr(0, null)); |
61 assertEquals(s, s.substr(0, String(s.length))); | 61 assertEquals(s, s.substr(0, String(s.length))); |
62 assertEquals('a', s.substr(0, true)); | 62 assertEquals('a', s.substr(0, true)); |
63 | 63 |
64 | 64 |
65 // Test substrings of different lengths and alignments. | 65 // Test substrings of different lengths and alignments. |
66 // First ASCII. | 66 // First ASCII. |
67 var x = "ASCII"; | 67 var x = "ASCII"; |
68 for (var i = 0; i < 25; i++) { | 68 for (var i = 0; i < 25; i++) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 last = z; | 145 last = z; |
146 cache.push(z); | 146 cache.push(z); |
147 offset += i; | 147 offset += i; |
148 } | 148 } |
149 for (var i = 63; i >= 0; i--) { | 149 for (var i = 63; i >= 0; i--) { |
150 var z = cache.pop(); | 150 var z = cache.pop(); |
151 assertTrue(/\u2028123456789ABCDEF/.test(z)); | 151 assertTrue(/\u2028123456789ABCDEF/.test(z)); |
152 assertEquals(xl - offset, z.length); | 152 assertEquals(xl - offset, z.length); |
153 offset -= i; | 153 offset -= i; |
154 } | 154 } |
OLD | NEW |