| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  138 var all_ascii_codes = []; |  138 var all_ascii_codes = []; | 
|  139 for (var i = 0; i < 128; i++) all_ascii_codes[i] = i; |  139 for (var i = 0; i < 128; i++) all_ascii_codes[i] = i; | 
|  140 var all_ascii_string = String.fromCharCode.apply(String, all_ascii_codes); |  140 var all_ascii_string = String.fromCharCode.apply(String, all_ascii_codes); | 
|  141  |  141  | 
|  142 var split_chars = all_ascii_string.split(""); |  142 var split_chars = all_ascii_string.split(""); | 
|  143 assertEquals(128, split_chars.length); |  143 assertEquals(128, split_chars.length); | 
|  144 for (var i = 0; i < 128; i++) { |  144 for (var i = 0; i < 128; i++) { | 
|  145   assertEquals(1, split_chars[i].length); |  145   assertEquals(1, split_chars[i].length); | 
|  146   assertEquals(i, split_chars[i].charCodeAt(0)); |  146   assertEquals(i, split_chars[i].charCodeAt(0)); | 
|  147 } |  147 } | 
 |  148  | 
 |  149 // Check that the separator is converted to string before returning due to | 
 |  150 // limit == 0. | 
 |  151 var counter = 0; | 
 |  152 var separator = { toString: function() { counter++; return "b"; }}; | 
 |  153 assertEquals([], "abc".split(separator, 0)); | 
 |  154 assertEquals(1, counter); | 
 |  155  | 
 |  156 // Check that the subject is converted to string before the separator. | 
 |  157 counter = 0; | 
 |  158 var subject = { toString: function() { assertEquals(0, counter); | 
 |  159                                        counter++; | 
 |  160                                        return "abc"; }}; | 
 |  161 separator = { toString: function() { assertEquals(1, counter); | 
 |  162                                      counter++; | 
 |  163                                      return "b"; }}; | 
 |  164  | 
 |  165 assertEquals(["a", "c"], String.prototype.split.call(subject, separator)); | 
 |  166 assertEquals(2, counter); | 
| OLD | NEW |