OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 // |
| 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions |
| 6 // are met: |
| 7 // 1. Redistributions of source code must retain the above copyright |
| 8 // notice, this list of conditions and the following disclaimer. |
| 9 // 2. Redistributions in binary form must reproduce the above copyright |
| 10 // notice, this list of conditions and the following disclaimer in the |
| 11 // documentation and/or other materials provided with the distribution. |
| 12 // |
| 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
| 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
| 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
| 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 |
| 24 description( |
| 25 |
| 26 "This test checks that toLowerCase and toUpperCase handle certain non-trivial ca
ses correctly." |
| 27 |
| 28 ); |
| 29 |
| 30 shouldBe('String("A𐐀").toLowerCase()', '"a𐐨"'); |
| 31 shouldBe('String("a𐐨").toUpperCase()', '"A𐐀"'); |
| 32 shouldBe('String("ΚΟΣΜΟΣ ΚΟΣΜΟΣ").toLowerCase()', '"κοσμος κοσμος"'); |
| 33 shouldBe('String("ß").toUpperCase()', '"SS"'); |
| 34 shouldBe('String("ʼn").toUpperCase()', '"ʼN"'); |
| 35 shouldBe('String("ǰ").toUpperCase()', '"J̌"'); |
| 36 shouldBe('String("ffi").toUpperCase()', '"FFI"'); |
| 37 shouldBe('String("FFI").toLowerCase()', '"ffi"'); |
| 38 shouldBe('String("IJ").toLowerCase()', '"ij"'); |
| 39 |
| 40 // Test the toUpper and toLower changes made in Unicode versions 5.2 and 6.1 |
| 41 // Construct the tests so that it passes if the toLowerCase()/toUpperCase() |
| 42 // either return the updated results for compliant platforms or the |
| 43 // passed in arguments if not. This should be changed when all platforms |
| 44 // support Unicode 5.2 and Unicode 6.1. |
| 45 function createExpected(/* ... */) |
| 46 { |
| 47 expected = {}; |
| 48 |
| 49 for (var i = 0; i < arguments.length; i++) { |
| 50 var s = String.fromCharCode(arguments[i]); |
| 51 expected[s] = true; |
| 52 } |
| 53 |
| 54 return expected; |
| 55 } |
| 56 |
| 57 // Check Unicode additions in version 5.2. From UnicodeData.txt: |
| 58 // 0265;LATIN SMALL LETTER TURNED H;Ll;0;L;;;;;N;;;A78D;;A78D |
| 59 // A78D;LATIN CAPITAL LETTER TURNED H;Lu;0;L;;;;;N;;;;0265; |
| 60 |
| 61 var expected = createExpected(0xA78D, 0x0265); |
| 62 shouldBeTrue('expected[String.fromCharCode(0xA78D).toLowerCase()]'); |
| 63 shouldBeTrue('expected[String.fromCharCode(0x0265).toUpperCase()]'); |
| 64 |
| 65 // Check Unicode additions in version 6.1 From UnicodeData.txt: |
| 66 // 0266;LATIN SMALL LETTER H WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER H HOOK;;A
7AA;;A7AA |
| 67 // 10C7;GEORGIAN CAPITAL LETTER YN;Lu;0;L;;;;;N;;;;2D27; |
| 68 // 10CD;GEORGIAN CAPITAL LETTER AEN;Lu;0;L;;;;;N;;;;2D2D; |
| 69 // 2CF2;COPTIC CAPITAL LETTER BOHAIRIC KHEI;Lu;0;L;;;;;N;;;;2CF3; |
| 70 // 2CF3;COPTIC SMALL LETTER BOHAIRIC KHEI;Ll;0;L;;;;;N;;;2CF2;;2CF2 |
| 71 // 2D27;GEORGIAN SMALL LETTER YN;Ll;0;L;;;;;N;;;10C7;;10C7 |
| 72 // 2D2D;GEORGIAN SMALL LETTER AEN;Ll;0;L;;;;;N;;;10CD;;10CD |
| 73 // A792;LATIN CAPITAL LETTER C WITH BAR;Lu;0;L;;;;;N;;;;A793; |
| 74 // A793;LATIN SMALL LETTER C WITH BAR;Ll;0;L;;;;;N;;;A792;;A792 |
| 75 // A7AA;LATIN CAPITAL LETTER H WITH HOOK;Lu;0;L;;;;;N;;;;0266; |
| 76 |
| 77 var expected = createExpected(0x10C7, 0x2D27); |
| 78 shouldBeTrue('expected[String.fromCharCode(0x10C7).toLowerCase()]'); |
| 79 shouldBeTrue('expected[String.fromCharCode(0x2D27).toUpperCase()]'); |
| 80 |
| 81 var expected = createExpected(0x10CD, 0x2D2D); |
| 82 shouldBeTrue('expected[String.fromCharCode(0x2D2D).toLowerCase()]'); |
| 83 shouldBeTrue('expected[String.fromCharCode(0x10CD).toUpperCase()]'); |
| 84 |
| 85 var expected = createExpected(0x2CF2, 0x2CF3); |
| 86 shouldBeTrue('expected[String.fromCharCode(0x2CF2).toLowerCase()]'); |
| 87 shouldBeTrue('expected[String.fromCharCode(0x2CF3).toUpperCase()]'); |
| 88 |
| 89 var expected = createExpected(0xA792, 0xA793); |
| 90 shouldBeTrue('expected[String.fromCharCode(0xA792).toLowerCase()]'); |
| 91 shouldBeTrue('expected[String.fromCharCode(0xA793).toUpperCase()]'); |
| 92 |
| 93 var expected = createExpected(0xA7AA, 0x0266); |
| 94 shouldBeTrue('expected[String.fromCharCode(0xA7AA).toLowerCase()]'); |
| 95 shouldBeTrue('expected[String.fromCharCode(0x0266).toUpperCase()]'); |
OLD | NEW |