~loic.molinari/+junk/qtdeclarative-shadereffectsource-changes

« back to all changes in this revision

Viewing changes to tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js

  • Committer: Loïc Molinari
  • Date: 2012-04-21 17:59:51 UTC
  • Revision ID: loic.molinari@canonical.com-20120421175951-bqx68caaf5zrp76l
Initial import

Show diffs side-by-side

added added

removed removed

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