Index: test/mjsunit/array-join.js |
=================================================================== |
--- test/mjsunit/array-join.js (revision 6989) |
+++ test/mjsunit/array-join.js (working copy) |
@@ -27,19 +27,44 @@ |
// Test that array join calls toString on subarrays. |
var a = [[1,2],3,4,[5,6]]; |
+assertEquals('1,2345,6', a.join('')); |
assertEquals('1,2*3*4*5,6', a.join('*')); |
+assertEquals('1,2**3**4**5,6', a.join('**')); |
+assertEquals('1,2****3****4****5,6', a.join('****')); |
+assertEquals('1,2********3********4********5,6', a.join('********')); |
+assertEquals('1,2**********3**********4**********5,6', a.join('**********')); |
// Create a cycle. |
a.push(a); |
+assertEquals('1,2345,6', a.join('')); |
assertEquals('1,2*3*4*5,6*', a.join('*')); |
+assertEquals('1,2**3**4**5,6**', a.join('**')); |
+assertEquals('1,2****3****4****5,6****', a.join('****')); |
+assertEquals('1,2********3********4********5,6********', a.join('********')); |
+assertEquals('1,2**********3**********4**********5,6**********', a.join('**********')); |
// Replace array.prototype.toString. |
Array.prototype.toString = function() { return "array"; } |
+assertEquals('array34arrayarray', a.join('')); |
assertEquals('array*3*4*array*array', a.join('*')); |
+assertEquals('array**3**4**array**array', a.join('**')); |
+assertEquals('array****3****4****array****array', a.join('****')); |
+assertEquals('array********3********4********array********array', a.join('********')); |
+assertEquals('array**********3**********4**********array**********array', a.join('**********')); |
Array.prototype.toString = function() { throw 42; } |
+assertThrows("a.join('')"); |
assertThrows("a.join('*')"); |
+assertThrows("a.join('**')"); |
+assertThrows("a.join('****')"); |
+assertThrows("a.join('********')"); |
+assertThrows("a.join('**********')"); |
Array.prototype.toString = function() { return "array"; } |
+assertEquals('array34arrayarray', a.join('')); |
assertEquals('array*3*4*array*array', a.join('*')); |
+assertEquals('array**3**4**array**array', a.join('**')); |
+assertEquals('array****3****4****array****array', a.join('****')); |
+assertEquals('array********3********4********array********array', a.join('********')); |
+assertEquals('array**********3**********4**********array**********array', a.join('**********')); |