NASHORN-503.js revision 6:5a1b0714df0e
172878Skris/* 272878Skris * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3100772Sjhb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4100772Sjhb * 5100772Sjhb * This code is free software; you can redistribute it and/or modify it 672878Skris * under the terms of the GNU General Public License version 2 only, as 7101232Sru * published by the Free Software Foundation. 8136606Sobrien * 9100773Sjhb * This code is distributed in the hope that it will be useful, but WITHOUT 10113374Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11126657Sbde * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12115175Speter * version 2 for more details (a copy is included in the LICENSE file that 13100773Sjhb * accompanied this code). 14103560Sjhb * 15176776Sraj * You should have received a copy of the GNU General Public License version 16176776Sraj * 2 along with this work; if not, write to the Free Software Foundation, 17100773Sjhb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18129217Scognet * 19129217Scognet * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20100773Sjhb * or visit www.oracle.com if you need additional information or have any 21100772Sjhb * questions. 2272878Skris */ 2372878Skris 2472878Skris/** 2572878Skris * NASHORN-503 : regression: closure loses context. 26100773Sjhb * 27166071Sdes * @test 28166071Sdes * @run 29166071Sdes */ 30166071Sdes 31136607Sobrienfunction next(f) { f(); } 32136606Sobrien 33136606Sobrientry { 34136606Sobrien throw new TypeError('error'); 35136606Sobrien} catch (iox) { 36136606Sobrien print('catch ' + iox.message); 37136606Sobrien next(function() { 38136606Sobrien print('next ' + iox.message); 39136606Sobrien }); 40136606Sobrien} 41136606Sobrien 42136606Sobrien 43136606Sobrientry { 44136606Sobrien throw new TypeError('error'); 45136606Sobrien} catch (iox) { 46136606Sobrien print('catch ' + iox.message); 47136606Sobrien next(function() { 48136606Sobrien var iox = {}; 49136607Sobrien print(iox.message); 50136607Sobrien }); 51133525Sobrien print('catch ' + iox.message); 52103045Smux} 53103045Smux