1425bb815Sopenharmony_ci// Copyright JS Foundation and other contributors, http://js.foundation
2425bb815Sopenharmony_ci//
3425bb815Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4425bb815Sopenharmony_ci// you may not use this file except in compliance with the License.
5425bb815Sopenharmony_ci// You may obtain a copy of the License at
6425bb815Sopenharmony_ci//
7425bb815Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8425bb815Sopenharmony_ci//
9425bb815Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10425bb815Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS
11425bb815Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12425bb815Sopenharmony_ci// See the License for the specific language governing permissions and
13425bb815Sopenharmony_ci// limitations under the License.
14425bb815Sopenharmony_ci
15425bb815Sopenharmony_ci// LATIN SMALL LIGATURES
16425bb815Sopenharmony_ci// LATIN SMALL LIGATURE FF
17425bb815Sopenharmony_ciassert ("\ufb00".toLowerCase() == "\ufb00");
18425bb815Sopenharmony_ciassert ("\ufb00".toUpperCase() == "\u0046\u0046");
19425bb815Sopenharmony_ci// LATIN SMALL LIGATURE FI
20425bb815Sopenharmony_ciassert ("\ufb01".toLowerCase() == "\ufb01");
21425bb815Sopenharmony_ciassert ("\ufb01".toUpperCase() == "\u0046\u0049");
22425bb815Sopenharmony_ci// LATIN SMALL LIGATURE FL
23425bb815Sopenharmony_ciassert ("\ufb02".toLowerCase() == "\ufb02");
24425bb815Sopenharmony_ciassert ("\ufb02".toUpperCase() == "\u0046\u004c");
25425bb815Sopenharmony_ci// LATIN SMALL LIGATURE FFI
26425bb815Sopenharmony_ciassert ("\ufb03".toLowerCase() == "\ufb03");
27425bb815Sopenharmony_ciassert ("\ufb03".toUpperCase() == "\u0046\u0046\u0049");
28425bb815Sopenharmony_ci// LATIN SMALL LIGATURE FFL
29425bb815Sopenharmony_ciassert ("\ufb04".toLowerCase() == "\ufb04");
30425bb815Sopenharmony_ciassert ("\ufb04".toUpperCase() == "\u0046\u0046\u004c");
31425bb815Sopenharmony_ci// LATIN SMALL LIGATURE LONG S T
32425bb815Sopenharmony_ciassert ("\ufb05".toLowerCase() == "\ufb05");
33425bb815Sopenharmony_ciassert ("\ufb05".toUpperCase() == "\u0053\u0054");
34425bb815Sopenharmony_ci// LATIN SMALL LIGATURE ST
35425bb815Sopenharmony_ciassert ("\ufb06".toLowerCase() == "\ufb06");
36425bb815Sopenharmony_ciassert ("\ufb06".toUpperCase() == "\u0053\u0054");
37425bb815Sopenharmony_ci
38425bb815Sopenharmony_ci// LATIN CAPITAL LETTER I WITH DOT ABOVE
39425bb815Sopenharmony_ciassert ("\u0130".toLowerCase() == "\u0069\u0307");
40425bb815Sopenharmony_ciassert ("\u0130".toUpperCase() == "\u0130");
41425bb815Sopenharmony_ci
42425bb815Sopenharmony_ci// LATIN SMALL LETTER SHARP S
43425bb815Sopenharmony_ciassert ("\u00df".toLowerCase() == "\u00df");
44425bb815Sopenharmony_ciassert ("\u00df".toUpperCase() == "\u0053\u0053");
45425bb815Sopenharmony_ci
46425bb815Sopenharmony_ci// LATIN CAPITAL LETTER I WITH BREVE
47425bb815Sopenharmony_ciassert ("\u012c".toLowerCase() == "\u012d");
48425bb815Sopenharmony_ciassert ("\u012c".toUpperCase() == "\u012c");
49425bb815Sopenharmony_ci// LATIN SMALL LETTER I WITH BREVE
50425bb815Sopenharmony_ciassert ("\u012d".toLowerCase() == "\u012d")
51425bb815Sopenharmony_ciassert ("\u012d".toUpperCase() == "\u012c");
52425bb815Sopenharmony_ci
53425bb815Sopenharmony_ci// Check randomly selected characters from conversion tables
54425bb815Sopenharmony_ci
55425bb815Sopenharmony_ci// lower-case conversions
56425bb815Sopenharmony_ciassert ("\u01c5\u01c8\u01cb\u212b".toLowerCase() == "\u01c6\u01c9\u01cc\u00e5");
57425bb815Sopenharmony_ciassert ("\u0130".toLowerCase() == "\u0069\u0307");
58425bb815Sopenharmony_ci
59425bb815Sopenharmony_ci// upper-case conversions
60425bb815Sopenharmony_ciassert ("\u00b5\u017f".toUpperCase() == "\u039c\u0053");
61425bb815Sopenharmony_ciassert ("\ufb17\u00df\u1fbc".toUpperCase() == "\u0544\u053D\u0053\u0053\u0391\u0399");
62425bb815Sopenharmony_ciassert ("\ufb03\ufb04".toUpperCase() == "\u0046\u0046\u0049\u0046\u0046\u004c");
63425bb815Sopenharmony_ci
64425bb815Sopenharmony_ci// character case ranges
65425bb815Sopenharmony_ciassert ("\u0100\u0101\u0139\u03fa\ua7b4".toLowerCase() == "\u0101\u0101\u013a\u03fb\ua7b5");
66425bb815Sopenharmony_ciassert ("\u0101\u0100\u013a\u03fb\ua7b5".toUpperCase() == "\u0100\u0100\u0139\u03fa\ua7b4");
67425bb815Sopenharmony_ci
68425bb815Sopenharmony_ci// character pairs
69425bb815Sopenharmony_ciassert ("\u0178\ua7b1\u0287\ua7b3".toLowerCase() == "\u00ff\u0287\u0287\uab53");
70425bb815Sopenharmony_ciassert ("\u00ff\u0287\ua7b1\uab53".toUpperCase() == "\u0178\ua7b1\ua7b1\ua7b3");
71425bb815Sopenharmony_ci
72425bb815Sopenharmony_ci// character case ranges
73425bb815Sopenharmony_ciassert ("\u00e0\u00c0\u00c1\u00c2\uff21".toLowerCase() == "\u00e0\u00e0\u00e1\u00e2\uff41");
74425bb815Sopenharmony_ciassert ("\u00e0\u00c0\u00e1\u00e2\uff41".toUpperCase() == "\u00c0\u00c0\u00c1\u00c2\uff21");
75425bb815Sopenharmony_ci
76425bb815Sopenharmony_ci// lower-case ranges
77425bb815Sopenharmony_ciassert ("\u1f88\u1f98\u1fa8\u1f8b\u1faf".toLowerCase() == "\u1f80\u1f90\u1fa0\u1f83\u1fa7");
78425bb815Sopenharmony_ci
79425bb815Sopenharmony_ci// upper-case special ranges
80425bb815Sopenharmony_ciassert ("\u1f80\u1f81\u1fa7".toUpperCase() == "\u1f08\u0399\u1f09\u0399\u1f6f\u0399");
81425bb815Sopenharmony_ci
82425bb815Sopenharmony_ciassert ("0123456789abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ".toLowerCase()
83425bb815Sopenharmony_ci        == "0123456789abcdefghijklmnopqrstuvwxzyabcdefghijklmnopqrstuvwxyz");
84425bb815Sopenharmony_ciassert ("0123456789abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ".toUpperCase()
85425bb815Sopenharmony_ci        == "0123456789ABCDEFGHIJKLMNOPQRSTUVWXZYABCDEFGHIJKLMNOPQRSTUVWXYZ");
86425bb815Sopenharmony_ci
87425bb815Sopenharmony_ci// Although codepoint 0x10400 and 0x10428 are an upper-lowercase pair,
88425bb815Sopenharmony_ci// we must not do their conversion in JavaScript. We must also ignore
89425bb815Sopenharmony_ci// stray surrogates.
90425bb815Sopenharmony_ci
91425bb815Sopenharmony_ciassert ("\ud801\ud801\udc00\udc00".toLowerCase() == "\ud801\ud801\udc00\udc00");
92425bb815Sopenharmony_ciassert ("\ud801\ud801\udc28\udc28".toUpperCase() == "\ud801\ud801\udc28\udc28");
93425bb815Sopenharmony_ci
94425bb815Sopenharmony_ci// Conversion of non-string objects.
95425bb815Sopenharmony_ci
96425bb815Sopenharmony_ciassert (String.prototype.toUpperCase.call(true) == "TRUE");
97425bb815Sopenharmony_ciassert (String.prototype.toLowerCase.call(-23) == "-23");
98425bb815Sopenharmony_ci
99425bb815Sopenharmony_civar object = { toString : function() { return "<sTr>"; } };
100425bb815Sopenharmony_ciassert (String.prototype.toUpperCase.call(object) == "<STR>");
101425bb815Sopenharmony_ciassert (String.prototype.toLowerCase.call(object) == "<str>");
102425bb815Sopenharmony_ci
103425bb815Sopenharmony_citry
104425bb815Sopenharmony_ci{
105425bb815Sopenharmony_ci  String.prototype.toUpperCase.call(null);
106425bb815Sopenharmony_ci  assert(false);
107425bb815Sopenharmony_ci}
108425bb815Sopenharmony_cicatch (e)
109425bb815Sopenharmony_ci{
110425bb815Sopenharmony_ci  assert (e instanceof TypeError);
111425bb815Sopenharmony_ci}
112