~ubuntu-branches/ubuntu/trusty/qtdeclarative-opensource-src/trusty-updates

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

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