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