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

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

Issue 11299163: Optimize non-ASCII string splitting with single-character search pattern (Closed)
Patch Set: Created 8 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/runtime.cc ('K') | « src/runtime.cc ('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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 assertArrayEquals(["a","","b"], "axxb".split(/x/)); 59 assertArrayEquals(["a","","b"], "axxb".split(/x/));
60 60
61 // This was http://b/issue?id=1151354 61 // This was http://b/issue?id=1151354
62 assertArrayEquals(["div", "#id", ".class"], "div#id.class".split(/(?=[#.])/)); 62 assertArrayEquals(["div", "#id", ".class"], "div#id.class".split(/(?=[#.])/));
63 63
64 64
65 assertArrayEquals(["div", "#i", "d", ".class"], "div#id.class".split(/(?=[d#.])/ )); 65 assertArrayEquals(["div", "#i", "d", ".class"], "div#id.class".split(/(?=[d#.])/ ));
66 66
67 assertArrayEquals(["a", "b", "c"], "abc".split(/(?=.)/)); 67 assertArrayEquals(["a", "b", "c"], "abc".split(/(?=.)/));
68 68
69 assertArrayEquals(["Wenige", "sind", "auserwählt."],
70 "Wenige sind auserwählt.".split(" "));
71
72 assertArrayEquals([], "Wenige sind auserwählt.".split(" ", 0));
73
74 assertArrayEquals(["Wenige"], "Wenige sind auserwählt.".split(" ", 1));
75
76 assertArrayEquals(["Wenige", "sind"], "Wenige sind auserwählt.".split(" ", 2));
77
78 assertArrayEquals(["Wenige", "sind", "auserwählt."],
79 "Wenige sind auserwählt.".split(" ", 3));
80
81 assertArrayEquals(["Wenige sind auserw", "hlt."],
82 "Wenige sind auserwählt.".split("ä"));
83
84 assertArrayEquals(["Wenige sind ", "."],
85 "Wenige sind auserwählt.".split("auserwählt"));
69 86
70 /* "ab".split(/((?=.))/) 87 /* "ab".split(/((?=.))/)
71 * 88 *
72 * KJS: ,a,,b 89 * KJS: ,a,,b
73 * SM: a,,b, 90 * SM: a,,b,
74 * IE: a,b 91 * IE: a,b
75 * Opera: a,,b 92 * Opera: a,,b
76 * V8: a,,b 93 * V8: a,,b
77 * 94 *
78 * Opera seems to have this right. The others make no sense. 95 * Opera seems to have this right. The others make no sense.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 var all_ascii_codes = []; 138 var all_ascii_codes = [];
122 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;
123 var all_ascii_string = String.fromCharCode.apply(String, all_ascii_codes); 140 var all_ascii_string = String.fromCharCode.apply(String, all_ascii_codes);
124 141
125 var split_chars = all_ascii_string.split(""); 142 var split_chars = all_ascii_string.split("");
126 assertEquals(128, split_chars.length); 143 assertEquals(128, split_chars.length);
127 for (var i = 0; i < 128; i++) { 144 for (var i = 0; i < 128; i++) {
128 assertEquals(1, split_chars[i].length); 145 assertEquals(1, split_chars[i].length);
129 assertEquals(i, split_chars[i].charCodeAt(0)); 146 assertEquals(i, split_chars[i].charCodeAt(0));
130 } 147 }
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698