|
1 /* |
|
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /** |
|
25 * JDK-8011714: Regexp decimal escape handling still not correct |
|
26 * |
|
27 * @test |
|
28 * @run |
|
29 */ |
|
30 |
|
31 // \0 should be interpreted as <NUL> character here |
|
32 print(/\08/.test("\x008")); |
|
33 print(/[\08]/.test("8")); |
|
34 print(/[\08]/.test("\x00")); |
|
35 |
|
36 // Can't be converted to octal thus encoded as literal char sequence |
|
37 print(/\8/.exec("\\8")); |
|
38 print(/[\8]/.exec("\\")); |
|
39 print(/[\8]/.exec("8")); |
|
40 |
|
41 // 0471 is too high for an octal escape so it is \047 outside a character class |
|
42 // and \\471 inside a character class |
|
43 print(/\471/.exec("\x271")); |
|
44 print(/[\471]/.exec("1")); |
|
45 print(/[\471]/.exec("\x27")); |
|
46 |
|
47 // 0366 is a valid octal escape (246) |
|
48 print(/\366/.test("\xf6")); |
|
49 print(/[\366]/.test("\xf6")); |
|
50 print(/[\366]/.test("\xf6")); |
|
51 |
|
52 // more tests for conversion of invalid backreferences to octal escapes or literals |
|
53 print(/(a)(b)(c)(d)\4/.exec("abcdd")); |
|
54 print(/(a)(b)(c)(d)\4x/.exec("abcddx")); |
|
55 print(/(a)(b)(c)(d)\47/.exec("abcdd7")); |
|
56 print(/(a)(b)(c)(d)\47/.exec("abcd\x27")); |
|
57 print(/(a)(b)(c)(d)\47xyz/.exec("abcd\x27xyz")); |
|
58 print(/(a)(b)(c)(d)[\47]/.exec("abcd\x27")); |
|
59 print(/(a)(b)(c)(d)[\47]xyz/.exec("abcd\x27xyz")); |
|
60 print(/(a)(b)(c)(d)\48/.exec("abcd\x048")); |
|
61 print(/(a)(b)(c)(d)\48xyz/.exec("abcd\x048xyz")); |
|
62 print(/(a)(b)(c)(d)[\48]/.exec("abcd\x04")); |
|
63 print(/(a)(b)(c)(d)[\48]xyz/.exec("abcd\x04xyz")); |
|
64 print(/(a)(b)(c)(d)\84/.exec("abcd84")); |
|
65 print(/(a)(b)(c)(d)\84xyz/.exec("abcd84xyz")); |
|
66 print(/(a)(b)(c)(d)[\84]/.exec("abcd8")); |
|
67 print(/(a)(b)(c)(d)[\84]xyz/.exec("abcd8xyz")); |
|
68 |