blob: 57d50701cd5807f059704657ff40bd5a3c424fee [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
5function 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
16function 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
27Test("a", "A");
28Test("0", "0");
29TestFail("a", "b");
30// Small and capital o-umlaut
31Test(String.fromCharCode(0xf6), String.fromCharCode(0xd6));
32// Small and capital kha.
33Test(String.fromCharCode(0x445), String.fromCharCode(0x425));
34// Small and capital y-umlaut.
35Test(String.fromCharCode(0xff), String.fromCharCode(0x178));
36// Small and large Greek mu.
37Test(String.fromCharCode(0x3bc), String.fromCharCode(0x39c));
38// Micron and large Greek mu.
39Test(String.fromCharCode(0xb5), String.fromCharCode(0x39c));
40// Micron and small Greek mu.
41Test(String.fromCharCode(0xb5), String.fromCharCode(0x3bc));
42// German double s and capital S. These are not equivalent since one is double.
43TestFail(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.
46TestFail("i", String.fromCharCode(0x130));
47// Small dotless i and I. These are not equivalent either.
48TestFail(String.fromCharCode(0x131), "I");