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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 assertEquals('array****3****4****array****array', a.join('****')); | 68 assertEquals('array****3****4****array****array', a.join('****')); |
69 assertEquals('array********3********4********array********array', a.join('******
**')); | 69 assertEquals('array********3********4********array********array', a.join('******
**')); |
70 assertEquals('array**********3**********4**********array**********array', a.join
('**********')); | 70 assertEquals('array**********3**********4**********array**********array', a.join
('**********')); |
71 | 71 |
72 // Restore original toString. | 72 // Restore original toString. |
73 delete Array.prototype.toString; | 73 delete Array.prototype.toString; |
74 if (Array.prototype.toString != oldToString) { | 74 if (Array.prototype.toString != oldToString) { |
75 Array.prototype.toString = oldToString; | 75 Array.prototype.toString = oldToString; |
76 } | 76 } |
77 | 77 |
78 var a = new Array(123123123); | 78 var a = new Array(123123); |
79 assertEquals(123123122, String(a).length); | 79 assertEquals(123122, String(a).length); |
80 assertEquals(123123122, a.join(",").length); | 80 assertEquals(123122, a.join(",").length); |
81 assertEquals(246246244, a.join("oo").length); | 81 assertEquals(246244, a.join("oo").length); |
82 | 82 |
83 a = new Array(Math.pow(2,32) - 1); // Max length. | 83 a = new Array(Math.pow(2,32) - 1); // Max length. |
84 assertEquals("", a.join("")); | 84 assertEquals("", a.join("")); |
85 a[123123123] = "o"; | 85 a[123123123] = "o"; |
86 a[1255215215] = "p"; | 86 a[1255215215] = "p"; |
87 assertEquals("op", a.join("")); | 87 assertEquals("op", a.join("")); |
88 | 88 |
89 a = new Array(100001); | 89 a = new Array(100001); |
90 for (var i = 0; i < a.length; i++) a[i] = undefined; | 90 for (var i = 0; i < a.length; i++) a[i] = undefined; |
91 a[5] = "ab"; | 91 a[5] = "ab"; |
92 a[90000] = "cd"; | 92 a[90000] = "cd"; |
93 assertEquals("abcd", a.join("")); // Must not throw. | 93 assertEquals("abcd", a.join("")); // Must not throw. |
OLD | NEW |