Bug 469739 - Add support for displaying Vista UAC shield icon; r=joe sr=vladimir
[wine-gecko.git] / js / tests / js1_8_1 / String / regress-305064.js
blob90eda33748695113d5ce778c79b69b75b87829be
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
18 * Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2007
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Mike Kaplinskiy <mike.kaplinskiy@gmail.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 var gTestfile = 'regress-305064.js';
40 //-----------------------------------------------------------------------------
41 var BUGNUMBER = 305064;
42 var summary = 'Tests the trim, trimRight and trimLeft methods';
43 var actual = '';
44 var expect = '';
46 printBugNumber(BUGNUMBER);
47 printStatus (summary);
49 var trimMethods = ['trim', 'trimLeft', 'trimRight'];
51 /** List from ES 3.1 Recommendation for String.trim (bug 305064) **/
52 var whitespace = [
53 {s : '\u0009', t : 'HORIZONTAL TAB'},
54 {s : '\u000B', t : 'VERTICAL TAB'},
55 {s : '\u000C', t : 'FORMFEED'},
56 {s : '\u0020', t : 'SPACE'},
57 {s : '\u00A0', t : 'NO-BREAK SPACE'},
58 {s : '\u1680', t : 'OGHAM SPACE MARK'},
59 {s : '\u180E', t : 'MONGOLIAN VOWEL SEPARATOR'},
60 {s : '\u2000', t : 'EN QUAD'},
61 {s : '\u2001', t : 'EM QUAD'},
62 {s : '\u2002', t : 'EN SPACE'},
63 {s : '\u2003', t : 'EM SPACE'},
64 {s : '\u2004', t : 'THREE-PER-EM SPACE'},
65 {s : '\u2005', t : 'FOUR-PER-EM SPACE'},
66 {s : '\u2006', t : 'SIX-PER-EM SPACE'},
67 {s : '\u2007', t : 'FIGURE SPACE'},
68 {s : '\u2008', t : 'PUNCTUATION SPACE'},
69 {s : '\u2009', t : 'THIN SPACE'},
70 {s : '\u200A', t : 'HAIR SPACE'},
71 {s : '\u202F', t : 'NARROW NO-BREAK SPACE'},
72 {s : '\u205F', t : 'MEDIUM MATHEMATICAL SPACE'},
73 {s : '\u3000', t : 'IDEOGRAPHIC SPACE'},
74 {s : '\u000A', t : 'LINE FEED OR NEW LINE'},
75 {s : '\u000D', t : 'CARRIAGE RETURN'},
76 {s : '\u2028', t : 'LINE SEPARATOR'},
77 {s : '\u2029', t : 'PARAGRAPH SEPARATOR'},
78 {s : '\u200B', t : 'ZERO WIDTH SPACE (category Cf)'}
81 for (var j = 0; j < trimMethods.length; ++j)
83 var str;
85 var method = trimMethods[j];
87 if (typeof String.prototype[method] == 'undefined')
89 reportCompare(true, true, 'Test skipped. String.prototype.' + method + ' is not supported');
90 continue;
93 print('Test empty string.');
94 str = '';
95 expected = '';
96 actual = str[method]();
97 reportCompare(expected, actual, '"' + toPrinted(str) + '".' + method + '()');
99 print('Test string with no whitespace.');
100 str = 'a';
101 expected = 'a';
102 actual = str[method]();
103 reportCompare(expected, actual, '"' + toPrinted(str) + '".' + method + '()');
105 for (var i = 0; i < whitespace.length; ++i)
107 var v = whitespace[i].s;
108 var t = whitespace[i].t;
109 v = v + v + v;
111 print('=======================================');
112 print('Test ' + method + ' with with only whitespace. : ' + t);
113 str = v;
114 expected = '';
115 actual = str[method]();
116 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
118 print('Test ' + method + ' with with no leading or trailing whitespace. : ' + t);
119 str = 'a' + v + 'b';
120 expected = str;
121 actual = str[method]();
122 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
124 print('Test ' + method + ' with with leading whitespace. : ' + t);
125 str = v + 'a';
126 switch(method)
128 case 'trim':
129 expected = 'a';
130 break;
131 case 'trimLeft':
132 expected = 'a';
133 break;
134 case 'trimRight':
135 expected = str;
136 break;
138 actual = str[method]();
139 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
141 print('Test ' + method + ' with with trailing whitespace. : ' + t);
142 str = 'a' + v;
143 switch(method)
145 case 'trim':
146 expected = 'a';
147 break;
148 case 'trimLeft':
149 expected = str;
150 break;
151 case 'trimRight':
152 expected = 'a';
153 break;
155 actual = str[method]();
156 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
158 print('Test ' + method + ' with with leading and trailing whitepace.');
159 str = v + 'a' + v;
160 switch(method)
162 case 'trim':
163 expected = 'a';
164 break;
165 case 'trimLeft':
166 expected = 'a' + v;
167 break;
168 case 'trimRight':
169 expected = v + 'a';
170 break;
172 actual = str[method]();
173 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');