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

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

Issue 119093002: Fix small spec violation in String.prototype.split. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/regress/regress-3026.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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-3026.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698