test/script/basic/JDK-8073868.js

Fri, 05 Jun 2015 12:38:53 +0200

author
mhaupt
date
Fri, 05 Jun 2015 12:38:53 +0200
changeset 1398
2f1b9f4daec1
parent 1270
dff9f4cfafd9
permissions
-rw-r--r--

8080087: Nashorn $ENV.PWD is originally undefined
Summary: On Windows, the PWD environment variable does not exist and cannot be imported in scripting mode, so it is set explicitly.
Reviewed-by: lagergren, sundar

hannesw@1270 1 /*
hannesw@1270 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hannesw@1270 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1270 4 *
hannesw@1270 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1270 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1270 7 * published by the Free Software Foundation.
hannesw@1270 8 *
hannesw@1270 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1270 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1270 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1270 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1270 13 * accompanied this code).
hannesw@1270 14 *
hannesw@1270 15 * You should have received a copy of the GNU General Public License version
hannesw@1270 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1270 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1270 18 *
hannesw@1270 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1270 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1270 21 * questions.
hannesw@1270 22 */
hannesw@1270 23
hannesw@1270 24 /**
hannesw@1270 25 * JDK-8073868: Regex matching causes java.lang.ArrayIndexOutOfBoundsException: 64
hannesw@1270 26 *
hannesw@1270 27 * @test
hannesw@1270 28 * @run
hannesw@1270 29 */
hannesw@1270 30
hannesw@1270 31 function test(input) {
hannesw@1270 32 var comma = input.indexOf(",");
hannesw@1270 33 Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[0], input.trimLeft());
hannesw@1270 34 Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[1], input.substring(0, comma).trimLeft());
hannesw@1270 35 Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[2], input.substring(comma + 1));
hannesw@1270 36 Assert.assertEquals(/(.*)+/.exec(input)[0], input);
hannesw@1270 37 Assert.assertEquals(/(.*)+/.exec(input)[1], input);
hannesw@1270 38 }
hannesw@1270 39
hannesw@1270 40 test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
hannesw@1270 41 test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
hannesw@1270 42 test("x, xxxxxxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
hannesw@1270 43
hannesw@1270 44 Assert.assertEquals(/(?:\1a|())*/.exec("a")[0], "a");
hannesw@1270 45 Assert.assertEquals(/(?:\1a|())*/.exec("a")[1], undefined);

mercurial