1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 function Test(lower, upper) { 6 var lx = lower + "x"; 7 var ux = upper + "x"; 8 var lp = lower + "|"; 9 var uxp = upper + "x|"; 10 assertEquals(lx, new RegExp(uxp + lp + lower + "cat", "i").exec(lx) + ""); 11 assertEquals(ux, new RegExp(uxp + lp + lower + "cat", "i").exec(ux) + ""); 12 assertEquals(lower, new RegExp(lp + uxp + lower + "cat", "i").exec(lx) + ""); 13 assertEquals(upper, new RegExp(lp + uxp + lower + "cat", "i").exec(ux) + ""); 14 } 15 16 function TestFail(lower, upper) { 17 var lx = lower + "x"; 18 var ux = upper + "x"; 19 var lp = lower + "|"; 20 var uxp = upper + "x|"; 21 assertEquals(lower, new RegExp(uxp + lp + lower + "cat", "i").exec(lx) + ""); 22 assertEquals(ux, new RegExp(uxp + lp + lower + "cat", "i").exec(ux) + ""); 23 assertEquals(lower, new RegExp(lp + uxp + lower + "cat", "i").exec(lx) + ""); 24 assertEquals(ux, new RegExp(lp + uxp + lower + "cat", "i").exec(ux) + ""); 25 } 26 27 Test("a", "A"); 28 Test("0", "0"); 29 TestFail("a", "b"); 30 // Small and capital o-umlaut 31 Test(String.fromCharCode(0xf6), String.fromCharCode(0xd6)); 32 // Small and capital kha. 33 Test(String.fromCharCode(0x445), String.fromCharCode(0x425)); 34 // Small and capital y-umlaut. 35 Test(String.fromCharCode(0xff), String.fromCharCode(0x178)); 36 // Small and large Greek mu. 37 Test(String.fromCharCode(0x3bc), String.fromCharCode(0x39c)); 38 // Micron and large Greek mu. 39 Test(String.fromCharCode(0xb5), String.fromCharCode(0x39c)); 40 // Micron and small Greek mu. 41 Test(String.fromCharCode(0xb5), String.fromCharCode(0x3bc)); 42 // German double s and capital S. These are not equivalent since one is double. 43 TestFail(String.fromCharCode(0xdf), "S"); 44 // Small i and Turkish capital dotted I. These are not equivalent due to 45 // 21.2.2.8.2 section 3g. One is below 128 and the other is above 127. 46 TestFail("i", String.fromCharCode(0x130)); 47 // Small dotless i and I. These are not equivalent either. 48 TestFail(String.fromCharCode(0x131), "I"); 49