Fri, 14 Jul 2017 14:30:06 -0700
Merge
hannesw@1841 | 1 | /* |
hannesw@1841 | 2 | * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
hannesw@1841 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
hannesw@1841 | 4 | * |
hannesw@1841 | 5 | * This code is free software; you can redistribute it and/or modify it |
hannesw@1841 | 6 | * under the terms of the GNU General Public License version 2 only, as |
hannesw@1841 | 7 | * published by the Free Software Foundation. |
hannesw@1841 | 8 | * |
hannesw@1841 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
hannesw@1841 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
hannesw@1841 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
hannesw@1841 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
hannesw@1841 | 13 | * accompanied this code). |
hannesw@1841 | 14 | * |
hannesw@1841 | 15 | * You should have received a copy of the GNU General Public License version |
hannesw@1841 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
hannesw@1841 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
hannesw@1841 | 18 | * |
hannesw@1841 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
hannesw@1841 | 20 | * or visit www.oracle.com if you need additional information or have any |
hannesw@1841 | 21 | * questions. |
hannesw@1841 | 22 | */ |
hannesw@1841 | 23 | |
hannesw@1841 | 24 | /** |
hannesw@1841 | 25 | * JDK-8137240: Negative lookahead in RegEx breaks backreference |
hannesw@1841 | 26 | * |
hannesw@1841 | 27 | * @test |
hannesw@1841 | 28 | * @run |
hannesw@1841 | 29 | */ |
hannesw@1841 | 30 | |
hannesw@1841 | 31 | |
hannesw@1841 | 32 | Assert.assertEquals('aa'.replace(/(a)(?!b)\1/gm, 'c'), 'c'); |
hannesw@1841 | 33 | |
hannesw@1841 | 34 | var result = 'aa'.match(/(a)(?!b)\1/); |
hannesw@1841 | 35 | Assert.assertTrue(result.length === 2); |
hannesw@1841 | 36 | Assert.assertTrue(result[0] === 'aa'); |
hannesw@1841 | 37 | Assert.assertTrue(result[1] === 'a'); |
hannesw@1841 | 38 | |
hannesw@1841 | 39 | result = 'aa'.match(/(a)(?!(b))\2(a)/); |
hannesw@1841 | 40 | Assert.assertTrue(result.length === 4); |
hannesw@1841 | 41 | Assert.assertTrue(result[0] === 'aa'); |
hannesw@1841 | 42 | Assert.assertTrue(result[1] === 'a'); |
hannesw@1841 | 43 | Assert.assertTrue(result[2] === undefined); |
hannesw@1841 | 44 | Assert.assertTrue(result[3] === 'a'); |