test/script/basic/JDK-8025515.js

Fri, 27 Sep 2013 16:59:01 +0200

author
hannesw
date
Fri, 27 Sep 2013 16:59:01 +0200
changeset 582
2016a6b9e1f3
child 750
23cbfa168a4e
permissions
-rw-r--r--

8025515: Performance issues with Source.getLine()
Reviewed-by: sundar, lagergren

hannesw@582 1 /*
hannesw@582 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
hannesw@582 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@582 4 *
hannesw@582 5 * This code is free software; you can redistribute it and/or modify it
hannesw@582 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@582 7 * published by the Free Software Foundation.
hannesw@582 8 *
hannesw@582 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@582 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@582 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@582 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@582 13 * accompanied this code).
hannesw@582 14 *
hannesw@582 15 * You should have received a copy of the GNU General Public License version
hannesw@582 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@582 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@582 18 *
hannesw@582 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@582 20 * or visit www.oracle.com if you need additional information or have any
hannesw@582 21 * questions.
hannesw@582 22 */
hannesw@582 23
hannesw@582 24 /**
hannesw@582 25 * JDK-8025515: Performance issues with Source.getLine()
hannesw@582 26 *
hannesw@582 27 * @test
hannesw@582 28 * @run
hannesw@582 29 */
hannesw@582 30
hannesw@582 31 // Make sure synthetic names of anonymous functions have correct line numbers
hannesw@582 32
hannesw@582 33 function testMethodName(f, expected) {
hannesw@582 34 try {
hannesw@582 35 f();
hannesw@582 36 fail("expected error");
hannesw@582 37 } catch (e) {
hannesw@582 38 var stack = e.getStackTrace();
hannesw@582 39 if (stack[0].methodName !== expected) {
hannesw@582 40 fail("got " + stack[0].methodName + ", expected " + expected);
hannesw@582 41 }
hannesw@582 42 }
hannesw@582 43 }
hannesw@582 44
hannesw@582 45 testMethodName(function() {
hannesw@582 46 return a.b.c;
hannesw@582 47 }, "_L45");
hannesw@582 48
hannesw@582 49 testMethodName(function() { throw new Error() }, "_L49");
hannesw@582 50
hannesw@582 51 var f = (function() {
hannesw@582 52 return function() { a.b.c; };
hannesw@582 53 })();
hannesw@582 54 testMethodName(f, "_L51$_L52");
hannesw@582 55
hannesw@582 56 testMethodName((function() {
hannesw@582 57 return function() { return a.b.c; };
hannesw@582 58 })(), "_L56$_L57");

mercurial