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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 assertArrayEquals(["a", "b"], "ab".split(/(?=)/)); | 90 assertArrayEquals(["a", "b"], "ab".split(/(?=)/)); |
91 | 91 |
92 | 92 |
93 // For issue http://code.google.com/p/v8/issues/detail?id=924 | 93 // For issue http://code.google.com/p/v8/issues/detail?id=924 |
94 // Splitting the empty string is a special case. | 94 // Splitting the empty string is a special case. |
95 assertEquals([""], ''.split()); | 95 assertEquals([""], ''.split()); |
96 assertEquals([""], ''.split(/./)); | 96 assertEquals([""], ''.split(/./)); |
97 assertEquals([], ''.split(/.?/)); | 97 assertEquals([], ''.split(/.?/)); |
98 assertEquals([], ''.split(/.??/)); | 98 assertEquals([], ''.split(/.??/)); |
99 assertEquals([], ''.split(/()()/)); | 99 assertEquals([], ''.split(/()()/)); |
| 100 |
| 101 |
| 102 // Issue http://code.google.com/p/v8/issues/detail?id=929 |
| 103 // (Splitting with empty separator and a limit.) |
| 104 |
| 105 function numberObj(num) { |
| 106 return {valueOf: function() { return num; }}; |
| 107 } |
| 108 |
| 109 assertEquals([], "abc".split("", 0)); |
| 110 assertEquals([], "abc".split("", numberObj(0))); |
| 111 assertEquals(["a"], "abc".split("", 1)); |
| 112 assertEquals(["a"], "abc".split("", numberObj(1))); |
| 113 assertEquals(["a", "b"], "abc".split("", 2)); |
| 114 assertEquals(["a", "b"], "abc".split("", numberObj(2))); |
| 115 assertEquals(["a", "b", "c"], "abc".split("", 3)); |
| 116 assertEquals(["a", "b", "c"], "abc".split("", numberObj(3))); |
| 117 assertEquals(["a", "b", "c"], "abc".split("", 4)); |
| 118 assertEquals(["a", "b", "c"], "abc".split("", numberObj(4))); |
OLD | NEW |