OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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'}, | 66 {s : '\u3000', t : 'IDEOGRAPHIC SPACE'}, |
67 {s : '\u2028', t : 'LINE SEPARATOR'}, | 67 {s : '\u2028', t : 'LINE SEPARATOR'}, |
68 {s : '\u2029', t : 'PARAGRAPH SEPARATOR'}, | 68 {s : '\u2029', t : 'PARAGRAPH SEPARATOR'}, |
69 {s : '\u200B', t : 'ZERO WIDTH SPACE (category Cf)'} | 69 // \u200B is not a whitespace character according to Unicode 6.3.0. |
| 70 // {s : '\u200B', t : 'ZERO WIDTH SPACE (category Cf)'} |
70 ]; | 71 ]; |
71 | 72 |
72 for (var i = 0; i < whitespace.length; i++) { | 73 for (var i = 0; i < whitespace.length; i++) { |
73 assertEquals(whitespace[i].s.trim(), ''); | 74 assertEquals(whitespace[i].s.trim(), ''); |
74 assertEquals(whitespace[i].s.trimLeft(), ''); | 75 assertEquals(whitespace[i].s.trimLeft(), ''); |
75 assertEquals(whitespace[i].s.trimRight(), ''); | 76 assertEquals(whitespace[i].s.trimRight(), ''); |
76 wsString += whitespace[i].s; | 77 wsString += whitespace[i].s; |
77 } | 78 } |
78 | 79 |
79 trimString = wsString + testString + wsString; | 80 trimString = wsString + testString + wsString; |
(...skipping 18 matching lines...) Expand all Loading... |
98 | 99 |
99 var testValues = [0, Infinity, NaN, true, false, ({}), ['an','array'], | 100 var testValues = [0, Infinity, NaN, true, false, ({}), ['an','array'], |
100 ({toString:function(){return 'wibble'}}) | 101 ({toString:function(){return 'wibble'}}) |
101 ]; | 102 ]; |
102 | 103 |
103 for (var i = 0; i < testValues.length; i++) { | 104 for (var i = 0; i < testValues.length; i++) { |
104 assertEquals(trim.call(testValues[i]), String(testValues[i])); | 105 assertEquals(trim.call(testValues[i]), String(testValues[i])); |
105 assertEquals(trimLeft.call(testValues[i]), String(testValues[i])); | 106 assertEquals(trimLeft.call(testValues[i]), String(testValues[i])); |
106 assertEquals(trimRight.call(testValues[i]), String(testValues[i])); | 107 assertEquals(trimRight.call(testValues[i]), String(testValues[i])); |
107 } | 108 } |
OLD | NEW |