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