Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: test/mjsunit/string-split.js

Issue 4750003: Make String.prototype.split honor limit when separator is empty. (Closed)
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/string.js ('K') | « src/string.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)));
OLDNEW
« src/string.js ('K') | « src/string.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698