Chromium Code Reviews| Index: test/mjsunit/regexp-sort.js |
| diff --git a/test/mjsunit/regexp-sort.js b/test/mjsunit/regexp-sort.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9304fb4802b32d7cf760b953ae6b91851fd79c00 |
| --- /dev/null |
| +++ b/test/mjsunit/regexp-sort.js |
| @@ -0,0 +1,40 @@ |
| +// 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) { |
| + assertEquals(lower + "x", new RegExp(upper + "x|" + lower + "|" + lower + "cat", "i").exec(lower + "x") + ""); |
| + assertEquals(upper + "x", new RegExp(upper + "x|" + lower + "|" + lower + "cat", "i").exec(upper + "x") + ""); |
| + assertEquals(lower, new RegExp(lower + "|" + upper + "x|" + lower + "cat", "i").exec(lower + "x") + ""); |
| + assertEquals(upper, new RegExp(lower + "|" + upper + "x|" + lower + "cat", "i").exec(upper + "x") + ""); |
| +} |
| + |
| +function TestFail(lower, upper) { |
| + assertEquals(lower, new RegExp(upper + "x|" + lower + "|" + lower + "cat", "i").exec(lower + "x") + ""); |
| + assertEquals(upper + "x", new RegExp(upper + "x|" + lower + "|" + lower + "cat", "i").exec(upper + "x") + ""); |
| + assertEquals(lower, new RegExp(lower + "|" + upper + "x|" + lower + "cat", "i").exec(lower + "x") + ""); |
| + assertEquals(upper + "x", new RegExp(lower + "|" + upper + "x|" + lower + "cat", "i").exec(upper + "x") + ""); |
| +} |
| + |
| +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)); |
|
Erik Corry Chromium.org
2015/06/17 07:21:13
Firefox fails this. I think we are doing it right
|
| +// 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"); |