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
32print(/\08/.test("\x008"));
33print(/[\08]/.test("8"));
34print(/[\08]/.test("\x00"));
35
36// Can't be converted to octal thus encoded as literal char sequence
37print(/\8/.exec("\\8"));
38print(/[\8]/.exec("\\"));
39print(/[\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
43print(/\471/.exec("\x271"));
44print(/[\471]/.exec("1"));
45print(/[\471]/.exec("\x27"));
46
47// 0366 is a valid octal escape (246)
48print(/\366/.test("\xf6"));
49print(/[\366]/.test("\xf6"));
50print(/[\366]/.test("\xf6"));
51
52// more tests for conversion of invalid backreferences to octal escapes or literals
53print(/(a)(b)(c)(d)\4/.exec("abcdd"));
54print(/(a)(b)(c)(d)\4x/.exec("abcddx"));
55print(/(a)(b)(c)(d)\47/.exec("abcdd7"));
56print(/(a)(b)(c)(d)\47/.exec("abcd\x27"));
57print(/(a)(b)(c)(d)\47xyz/.exec("abcd\x27xyz"));
58print(/(a)(b)(c)(d)[\47]/.exec("abcd\x27"));
59print(/(a)(b)(c)(d)[\47]xyz/.exec("abcd\x27xyz"));
60print(/(a)(b)(c)(d)\48/.exec("abcd\x048"));
61print(/(a)(b)(c)(d)\48xyz/.exec("abcd\x048xyz"));
62print(/(a)(b)(c)(d)[\48]/.exec("abcd\x04"));
63print(/(a)(b)(c)(d)[\48]xyz/.exec("abcd\x04xyz"));
64print(/(a)(b)(c)(d)\84/.exec("abcd84"));
65print(/(a)(b)(c)(d)\84xyz/.exec("abcd84xyz"));
66print(/(a)(b)(c)(d)[\84]/.exec("abcd8"));
67print(/(a)(b)(c)(d)[\84]xyz/.exec("abcd8xyz"));
68
69