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