throw.js revision 1224:065b159bb922
131567Ssef/*
231899Ssef * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
331899Ssef * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
431899Ssef *
531899Ssef * This code is free software; you can redistribute it and/or modify it
631899Ssef * under the terms of the GNU General Public License version 2 only, as
731899Ssef * published by the Free Software Foundation.
831899Ssef *
931899Ssef * This code is distributed in the hope that it will be useful, but WITHOUT
1031899Ssef * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1131899Ssef * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1231899Ssef * version 2 for more details (a copy is included in the LICENSE file that
1331899Ssef * accompanied this code).
1431899Ssef *
1531899Ssef * You should have received a copy of the GNU General Public License version
1631899Ssef * 2 along with this work; if not, write to the Free Software Foundation,
1731899Ssef * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1831899Ssef *
1931899Ssef * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2031899Ssef * or visit www.oracle.com if you need additional information or have any
2131899Ssef * questions.
2231899Ssef */
2331899Ssef
2431899Ssef/**
2531899Ssef * Tests to check representation throw statement tree.
2631899Ssef *
2731899Ssef * @test
2831899Ssef * @bug 8068306
2931899Ssef * @option -scripting
3031899Ssef * @run
3131899Ssef */
3232275Scharnier
3332275Scharnierload(__DIR__ + "utils.js")
3450477Speter
3532275Scharnier
3632275Scharniervar code = <<EOF
3731899Ssef
3831567Ssefthrow err;
3931567Ssefthrow 'wrong';
4031567Ssefthrow new TypeError;
4131567Ssefthrow new TypeError('not an array');
42127328Salfredthrow { msg: 'wrong!' };
4385292Sdes
4485292SdesEOF
45104581Smike
4685292Sdesparse("throw.js", code, "-nse", new (Java.extend(visitor, {
4785292Sdes    visitThrow: function (node, obj) {
4885292Sdes        obj.push(convert(node))
4985292Sdes    }
5086138Sgreen})))