Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / String / 15.5.4.11-1.js
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
4  *
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/
9  *
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.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *
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.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39 gTestfile = '15.5.4.11-1.js';
40
41 /**
42    File Name:          15.5.4.11-1.js
43    ECMA Section:       15.5.4.11 String.prototype.toLowerCase()
44    Description:
45
46    Returns a string equal in length to the length of the result of converting
47    this object to a string. The result is a string value, not a String object.
48
49    Every character of the result is equal to the corresponding character of the
50    string, unless that character has a Unicode 2.0 uppercase equivalent, in which
51    case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case
52    mapping shall be used, which does not depend on implementation or locale.)
53
54    Note that the toLowerCase function is intentionally generic; it does not require
55    that its this value be a String object. Therefore it can be transferred to other
56    kinds of objects for use as a method.
57
58    Author:             christine@netscape.com
59    Date:               12 november 1997
60 */
61
62 var SECTION = "15.5.4.11-1";
63 var VERSION = "ECMA_1";
64 startTest();
65 var TITLE   = "String.prototype.toLowerCase()";
66
67 writeHeaderToLog( SECTION + " "+ TITLE);
68
69 new TestCase( SECTION,  "String.prototype.toLowerCase.length",        0,          String.prototype.toLowerCase.length );
70 new TestCase( SECTION,  "delete String.prototype.toLowerCase.length", false,      delete String.prototype.toLowerCase.length );
71 new TestCase( SECTION,  "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0,      eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") );
72
73 // Basic Latin, Latin-1 Supplement, Latin Extended A
74 for ( var i = 0; i <= 0x017f; i++ ) {
75   var U = new Unicode(i);
76 /*
77   new TestCase(   SECTION,
78   "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()",
79   String.fromCharCode(U.lower),
80   eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") );
81 */
82   new TestCase(   SECTION,
83                   "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)",
84                   U.lower,
85                   eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") );
86
87 }
88
89 test();
90
91 function MyObject( value ) {
92   this.value = value;
93   this.substring = String.prototype.substring;
94   this.toString = new Function ( "return this.value+''" );
95 }
96 function Unicode( c ) {
97   u = GetUnicodeValues( c );
98   this.upper = u[0];
99   this.lower = u[1]
100     return this;
101 }
102 function GetUnicodeValues( c ) {
103   u = new Array();
104
105   u[0] = c;
106   u[1] = c;
107
108   // upper case Basic Latin
109
110   if ( c >= 0x0041 && c <= 0x005A) {
111     u[0] = c;
112     u[1] = c + 32;
113     return u;
114   }
115
116   // lower case Basic Latin
117   if ( c >= 0x0061 && c <= 0x007a ) {
118     u[0] = c - 32;
119     u[1] = c;
120     return u;
121   }
122
123   // upper case Latin-1 Supplement
124   if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) {
125     u[0] = c;
126     u[1] = c + 32;
127     return u;
128   }
129
130   // lower case Latin-1 Supplement
131   if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) {
132     u[0] = c - 32;
133     u[1] = c;
134     return u;
135   }
136   if ( c == 0x00FF ) {
137     u[0] = 0x0178;
138     u[1] = c;
139     return u;
140   }
141   // Latin Extended A
142   if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) {
143     // special case for capital I
144     if ( c == 0x0130 ) {
145       u[0] = c;
146       u[1] = 0x0069;
147       return u;
148     }
149     if ( c == 0x0131 ) {
150       u[0] = 0x0049;
151       u[1] = c;
152       return u;
153     }
154
155     if ( c % 2 == 0 ) {
156       // if it's even, it's a capital and the lower case is c +1
157       u[0] = c;
158       u[1] = c+1;
159     } else {
160       // if it's odd, it's a lower case and upper case is c-1
161       u[0] = c-1;
162       u[1] = c;
163     }
164     return u;
165   }
166   if ( c == 0x0178 ) {
167     u[0] = c;
168     u[1] = 0x00FF;
169     return u;
170   }
171
172   if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) {
173     if ( c % 2 == 1 ) {
174       // if it's odd, it's a capital and the lower case is c +1
175       u[0] = c;
176       u[1] = c+1;
177     } else {
178       // if it's even, it's a lower case and upper case is c-1
179       u[0] = c-1;
180       u[1] = c;
181     }
182     return u;
183   }
184   if ( c == 0x017F ) {
185     u[0] = 0x0053;
186     u[1] = c;
187   }
188
189   // Latin Extended B
190   // need to improve this set
191
192   if ( c >= 0x0200 && c <= 0x0217 ) {
193     if ( c % 2 == 0 ) {
194       u[0] = c;
195       u[1] = c+1;
196     } else {
197       u[0] = c-1;
198       u[1] = c;
199     }
200     return u;
201   }
202
203   // Latin Extended Additional
204   // Range: U+1E00 to U+1EFF
205   // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html
206
207   // Spacing Modifier Leters
208   // Range: U+02B0 to U+02FF
209
210   // Combining Diacritical Marks
211   // Range: U+0300 to U+036F
212
213   // skip Greek for now
214   // Greek
215   // Range: U+0370 to U+03FF
216
217   // Cyrillic
218   // Range: U+0400 to U+04FF
219
220   if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) {
221     u[0] = c;
222     u[1] = c + 80;
223     return u;
224   }
225
226
227   if ( c >= 0x0410  && c <= 0x042F ) {
228     u[0] = c;
229     u[1] = c + 32;
230     return u;
231   }
232
233   if ( c >= 0x0430 && c<= 0x044F ) {
234     u[0] = c - 32;
235     u[1] = c;
236     return u;
237
238   }
239   if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) {
240     u[0] = c -80;
241     u[1] = c;
242     return u;
243   }
244
245   if ( c >= 0x0460 && c <= 0x047F ) {
246     if ( c % 2 == 0 ) {
247       u[0] = c;
248       u[1] = c +1;
249     } else {
250       u[0] = c - 1;
251       u[1] = c;
252     }
253     return u;
254   }
255
256   // Armenian
257   // Range: U+0530 to U+058F
258   if ( c >= 0x0531 && c <= 0x0556 ) {
259     u[0] = c;
260     u[1] = c + 48;
261     return u;
262   }
263   if ( c >= 0x0561 && c < 0x0587 ) {
264     u[0] = c - 48;
265     u[1] = c;
266     return u;
267   }
268
269   // Hebrew
270   // Range: U+0590 to U+05FF
271
272
273   // Arabic
274   // Range: U+0600 to U+06FF
275
276   // Devanagari
277   // Range: U+0900 to U+097F
278
279
280   // Bengali
281   // Range: U+0980 to U+09FF
282
283
284   // Gurmukhi
285   // Range: U+0A00 to U+0A7F
286
287
288   // Gujarati
289   // Range: U+0A80 to U+0AFF
290
291
292   // Oriya
293   // Range: U+0B00 to U+0B7F
294   // no capital / lower case
295
296
297   // Tamil
298   // Range: U+0B80 to U+0BFF
299   // no capital / lower case
300
301
302   // Telugu
303   // Range: U+0C00 to U+0C7F
304   // no capital / lower case
305
306
307   // Kannada
308   // Range: U+0C80 to U+0CFF
309   // no capital / lower case
310
311
312   // Malayalam
313   // Range: U+0D00 to U+0D7F
314
315   // Thai
316   // Range: U+0E00 to U+0E7F
317
318
319   // Lao
320   // Range: U+0E80 to U+0EFF
321
322
323   // Tibetan
324   // Range: U+0F00 to U+0FBF
325
326   // Georgian
327   // Range: U+10A0 to U+10F0
328   if ( c >= 0x10A0 && c <= 0x10C5 ) {
329     u[0] = c;
330     u[1] = c + 48;
331     return u;
332   }
333   if ( c >= 0x10D0 && c <= 0x10F5 ) {
334     u[0] = c;
335     u[1] = c;
336     return u;
337   }
338
339   // Hangul Jamo
340   // Range: U+1100 to U+11FF
341
342   // Greek Extended
343   // Range: U+1F00 to U+1FFF
344   // skip for now
345
346
347   // General Punctuation
348   // Range: U+2000 to U+206F
349
350   // Superscripts and Subscripts
351   // Range: U+2070 to U+209F
352
353   // Currency Symbols
354   // Range: U+20A0 to U+20CF
355
356
357   // Combining Diacritical Marks for Symbols
358   // Range: U+20D0 to U+20FF
359   // skip for now
360
361
362   // Number Forms
363   // Range: U+2150 to U+218F
364   // skip for now
365
366
367   // Arrows
368   // Range: U+2190 to U+21FF
369
370   // Mathematical Operators
371   // Range: U+2200 to U+22FF
372
373   // Miscellaneous Technical
374   // Range: U+2300 to U+23FF
375
376   // Control Pictures
377   // Range: U+2400 to U+243F
378
379   // Optical Character Recognition
380   // Range: U+2440 to U+245F
381
382   // Enclosed Alphanumerics
383   // Range: U+2460 to U+24FF
384
385   // Box Drawing
386   // Range: U+2500 to U+257F
387
388   // Block Elements
389   // Range: U+2580 to U+259F
390
391   // Geometric Shapes
392   // Range: U+25A0 to U+25FF
393
394   // Miscellaneous Symbols
395   // Range: U+2600 to U+26FF
396
397   // Dingbats
398   // Range: U+2700 to U+27BF
399
400   // CJK Symbols and Punctuation
401   // Range: U+3000 to U+303F
402
403   // Hiragana
404   // Range: U+3040 to U+309F
405
406   // Katakana
407   // Range: U+30A0 to U+30FF
408
409   // Bopomofo
410   // Range: U+3100 to U+312F
411
412   // Hangul Compatibility Jamo
413   // Range: U+3130 to U+318F
414
415   // Kanbun
416   // Range: U+3190 to U+319F
417
418
419   // Enclosed CJK Letters and Months
420   // Range: U+3200 to U+32FF
421
422   // CJK Compatibility
423   // Range: U+3300 to U+33FF
424
425   // Hangul Syllables
426   // Range: U+AC00 to U+D7A3
427
428   // High Surrogates
429   // Range: U+D800 to U+DB7F
430
431   // Private Use High Surrogates
432   // Range: U+DB80 to U+DBFF
433
434   // Low Surrogates
435   // Range: U+DC00 to U+DFFF
436
437   // Private Use Area
438   // Range: U+E000 to U+F8FF
439
440   // CJK Compatibility Ideographs
441   // Range: U+F900 to U+FAFF
442
443   // Alphabetic Presentation Forms
444   // Range: U+FB00 to U+FB4F
445
446   // Arabic Presentation Forms-A
447   // Range: U+FB50 to U+FDFF
448
449   // Combining Half Marks
450   // Range: U+FE20 to U+FE2F
451
452   // CJK Compatibility Forms
453   // Range: U+FE30 to U+FE4F
454
455   // Small Form Variants
456   // Range: U+FE50 to U+FE6F
457
458   // Arabic Presentation Forms-B
459   // Range: U+FE70 to U+FEFF
460
461   // Halfwidth and Fullwidth Forms
462   // Range: U+FF00 to U+FFEF
463
464   if ( c >= 0xFF21 && c <= 0xFF3A ) {
465     u[0] = c;
466     u[1] = c + 32;
467     return u;
468   }
469
470   if ( c >= 0xFF41 && c <= 0xFF5A ) {
471     u[0] = c - 32;
472     u[1] = c;
473     return u;
474   }
475
476   // Specials
477   // Range: U+FFF0 to U+FFFF
478
479   return u;
480 }
481
482 function DecimalToHexString( n ) {
483   n = Number( n );
484   var h = "0x";
485
486   for ( var i = 3; i >= 0; i-- ) {
487     if ( n >= Math.pow(16, i) ){
488       var t = Math.floor( n  / Math.pow(16, i));
489       n -= t * Math.pow(16, i);
490       if ( t >= 10 ) {
491         if ( t == 10 ) {
492           h += "A";
493         }
494         if ( t == 11 ) {
495           h += "B";
496         }
497         if ( t == 12 ) {
498           h += "C";
499         }
500         if ( t == 13 ) {
501           h += "D";
502         }
503         if ( t == 14 ) {
504           h += "E";
505         }
506         if ( t == 15 ) {
507           h += "F";
508         }
509       } else {
510         h += String( t );
511       }
512     } else {
513       h += "0";
514     }
515   }
516
517   return h;
518 }