summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/regexp-sort.js
blob: 57d50701cd5807f059704657ff40bd5a3c424fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

function Test(lower, upper) {
  var lx = lower + "x";
  var ux = upper + "x";
  var lp = lower + "|";
  var uxp = upper + "x|";
  assertEquals(lx, new RegExp(uxp + lp + lower + "cat", "i").exec(lx) + "");
  assertEquals(ux, new RegExp(uxp + lp + lower + "cat", "i").exec(ux) + "");
  assertEquals(lower, new RegExp(lp + uxp + lower + "cat", "i").exec(lx) + "");
  assertEquals(upper, new RegExp(lp + uxp + lower + "cat", "i").exec(ux) + "");
}

function TestFail(lower, upper) {
  var lx = lower + "x";
  var ux = upper + "x";
  var lp = lower + "|";
  var uxp = upper + "x|";
  assertEquals(lower, new RegExp(uxp + lp + lower + "cat", "i").exec(lx) + "");
  assertEquals(ux, new RegExp(uxp + lp + lower + "cat", "i").exec(ux) + "");
  assertEquals(lower, new RegExp(lp + uxp + lower + "cat", "i").exec(lx) + "");
  assertEquals(ux, new RegExp(lp + uxp + lower + "cat", "i").exec(ux) + "");
}

Test("a", "A");
Test("0", "0");
TestFail("a", "b");
// Small and capital o-umlaut
Test(String.fromCharCode(0xf6), String.fromCharCode(0xd6));
// Small and capital kha.
Test(String.fromCharCode(0x445), String.fromCharCode(0x425));
// Small and capital y-umlaut.
Test(String.fromCharCode(0xff), String.fromCharCode(0x178));
// Small and large Greek mu.
Test(String.fromCharCode(0x3bc), String.fromCharCode(0x39c));
// Micron and large Greek mu.
Test(String.fromCharCode(0xb5), String.fromCharCode(0x39c));
// Micron and small Greek mu.
Test(String.fromCharCode(0xb5), String.fromCharCode(0x3bc));
// German double s and capital S. These are not equivalent since one is double.
TestFail(String.fromCharCode(0xdf), "S");
// Small i and Turkish capital dotted I. These are not equivalent due to
// 21.2.2.8.2 section 3g.  One is below 128 and the other is above 127.
TestFail("i", String.fromCharCode(0x130));
// Small dotless i and I. These are not equivalent either.
TestFail(String.fromCharCode(0x131), "I");