hannesw@582: /* hannesw@582: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. hannesw@582: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@582: * hannesw@582: * This code is free software; you can redistribute it and/or modify it hannesw@582: * under the terms of the GNU General Public License version 2 only, as hannesw@582: * published by the Free Software Foundation. hannesw@582: * hannesw@582: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@582: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@582: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@582: * version 2 for more details (a copy is included in the LICENSE file that hannesw@582: * accompanied this code). hannesw@582: * hannesw@582: * You should have received a copy of the GNU General Public License version hannesw@582: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@582: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@582: * hannesw@582: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@582: * or visit www.oracle.com if you need additional information or have any hannesw@582: * questions. hannesw@582: */ hannesw@582: hannesw@582: /** hannesw@582: * JDK-8025515: Performance issues with Source.getLine() hannesw@582: * hannesw@582: * @test hannesw@582: * @run hannesw@582: */ hannesw@582: hannesw@582: // Make sure synthetic names of anonymous functions have correct line numbers hannesw@582: hannesw@582: function testMethodName(f, expected) { hannesw@582: try { hannesw@582: f(); hannesw@582: fail("expected error"); hannesw@582: } catch (e) { hannesw@582: var stack = e.getStackTrace(); hannesw@582: if (stack[0].methodName !== expected) { hannesw@582: fail("got " + stack[0].methodName + ", expected " + expected); hannesw@582: } hannesw@582: } hannesw@582: } hannesw@582: hannesw@582: testMethodName(function() { hannesw@582: return a.b.c; hannesw@582: }, "_L45"); hannesw@582: hannesw@582: testMethodName(function() { throw new Error() }, "_L49"); hannesw@582: hannesw@582: var f = (function() { hannesw@582: return function() { a.b.c; }; hannesw@582: })(); hannesw@582: testMethodName(f, "_L51$_L52"); hannesw@582: hannesw@582: testMethodName((function() { hannesw@582: return function() { return a.b.c; }; hannesw@582: })(), "_L56$_L57");