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

Side by Side Diff: test/mjsunit/third_party/string-trim.js

Issue 11293277: Fix string whitespace trimming of 0x200b and NEL character. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/regress/regress-2408.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 (c) 2009 Apple Computer, Inc. All rights reserved. 1 // Copyright (c) 2009 Apple Computer, Inc. All rights reserved.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions 4 // modification, are permitted provided that the following conditions
5 // are met: 5 // are met:
6 // 6 //
7 // 1. Redistributions of source code must retain the above copyright 7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // 9 //
10 // 2. Redistributions in binary form must reproduce the above 10 // 2. Redistributions in binary form must reproduce the above
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 {s : '\u2001', t : 'EM QUAD'}, 56 {s : '\u2001', t : 'EM QUAD'},
57 {s : '\u2002', t : 'EN SPACE'}, 57 {s : '\u2002', t : 'EN SPACE'},
58 {s : '\u2003', t : 'EM SPACE'}, 58 {s : '\u2003', t : 'EM SPACE'},
59 {s : '\u2004', t : 'THREE-PER-EM SPACE'}, 59 {s : '\u2004', t : 'THREE-PER-EM SPACE'},
60 {s : '\u2005', t : 'FOUR-PER-EM SPACE'}, 60 {s : '\u2005', t : 'FOUR-PER-EM SPACE'},
61 {s : '\u2006', t : 'SIX-PER-EM SPACE'}, 61 {s : '\u2006', t : 'SIX-PER-EM SPACE'},
62 {s : '\u2007', t : 'FIGURE SPACE'}, 62 {s : '\u2007', t : 'FIGURE SPACE'},
63 {s : '\u2008', t : 'PUNCTUATION SPACE'}, 63 {s : '\u2008', t : 'PUNCTUATION SPACE'},
64 {s : '\u2009', t : 'THIN SPACE'}, 64 {s : '\u2009', t : 'THIN SPACE'},
65 {s : '\u200A', t : 'HAIR SPACE'}, 65 {s : '\u200A', t : 'HAIR SPACE'},
66 {s : '\u3000', t : 'IDEOGRAPHIC SPACE'},
67 {s : '\u2028', t : 'LINE SEPARATOR'}, 66 {s : '\u2028', t : 'LINE SEPARATOR'},
68 {s : '\u2029', t : 'PARAGRAPH SEPARATOR'}, 67 {s : '\u2029', t : 'PARAGRAPH SEPARATOR'},
69 {s : '\u200B', t : 'ZERO WIDTH SPACE (category Cf)'} 68 {s : '\u202F', t : 'NARROW NO-BREAK SPACE'},
69 {s : '\u205F', t : 'MEDIUM MATHEMATICAL SPACE'},
70 {s : '\u3000', t : 'IDEOGRAPHIC SPACE'},
71 {s : '\uFEFF', t : 'BYTE ORDER MARK'}
70 ]; 72 ];
71 73
72 for (var i = 0; i < whitespace.length; i++) { 74 for (var i = 0; i < whitespace.length; i++) {
73 assertEquals(whitespace[i].s.trim(), ''); 75 assertEquals(whitespace[i].s.trim(), '');
74 assertEquals(whitespace[i].s.trimLeft(), ''); 76 assertEquals(whitespace[i].s.trimLeft(), '');
75 assertEquals(whitespace[i].s.trimRight(), ''); 77 assertEquals(whitespace[i].s.trimRight(), '');
76 wsString += whitespace[i].s; 78 wsString += whitespace[i].s;
77 } 79 }
78 80
79 trimString = wsString + testString + wsString; 81 trimString = wsString + testString + wsString;
(...skipping 18 matching lines...) Expand all
98 100
99 var testValues = [0, Infinity, NaN, true, false, ({}), ['an','array'], 101 var testValues = [0, Infinity, NaN, true, false, ({}), ['an','array'],
100 ({toString:function(){return 'wibble'}}) 102 ({toString:function(){return 'wibble'}})
101 ]; 103 ];
102 104
103 for (var i = 0; i < testValues.length; i++) { 105 for (var i = 0; i < testValues.length; i++) {
104 assertEquals(trim.call(testValues[i]), String(testValues[i])); 106 assertEquals(trim.call(testValues[i]), String(testValues[i]));
105 assertEquals(trimLeft.call(testValues[i]), String(testValues[i])); 107 assertEquals(trimLeft.call(testValues[i]), String(testValues[i]));
106 assertEquals(trimRight.call(testValues[i]), String(testValues[i])); 108 assertEquals(trimRight.call(testValues[i]), String(testValues[i]));
107 } 109 }
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-2408.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698