test/nashorn/script/basic/NASHORN-58.js
author erikj
Tue, 12 Sep 2017 19:03:56 +0200
changeset 47217 72e3ae9a25eb
parent 47216 71c04702a3d5
permissions -rw-r--r--
8187444: Forest Consolidation: Make build work Reviewed-by: darcy, ihse Contributed-by: erik.joelsson@oracle.com, maurizio.cimadamore@oracle.com, sundararajan.athijegannathan@oracle.com, jonathan.gibbons@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
     4
 *
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
     8
 *
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    14
 *
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    18
 *
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    23
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
/**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
 * NASHORN-58
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
 * @test
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
 * @run
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    30
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
function test1() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
    var x = 1;
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    33
    try {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    34
    print('try');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    35
    x = 2;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
    } catch(e) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    37
    print('catch');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    38
    } finally {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    39
    print('finally');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    40
    x = 3;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    41
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
    print(x);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    44
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
function test2() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    46
    var x = 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    48
    print('try');
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
    } finally {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    50
    print('finally');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    51
    x = 2;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
    print(x);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    55
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    56
function test3() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    57
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    58
    return 2;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    59
    } finally {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    60
    return 3;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
function test4() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    65
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    66
    x = 1;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    67
    print(x);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    68
    try {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    69
        x = 2;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    70
        print(x);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
    } finally {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    72
        x = 3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    73
        print(x)
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    74
        try {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    75
        x = 4;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    76
        print(x);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    77
        } finally {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    78
        x = 5;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    79
        print(x);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    80
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    81
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    82
    print(x)
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    83
    } finally {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    84
    x = 6;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    85
    print(x);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
    print(x);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    90
function test5() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    91
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    92
    x = 1;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    93
    print(x);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    94
    try {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    95
        x = 2;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    96
        print(x);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    97
    } finally {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    98
        x = 3;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
    99
        print(x)
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   100
        try {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   101
        x = 4;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   102
        print(x);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   103
        } finally {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   104
        x = 5;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   105
        return x;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   106
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   107
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   108
    print(x)
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   109
    } finally {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   110
    x = 6;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   111
    return x;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   112
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   113
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   114
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   115
function test6() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   116
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   117
    throw new Error("testing");
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   118
    } catch (ex) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   119
    print(ex);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   120
    return;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   121
    } finally {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   122
    print("finally");
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   123
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   124
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   125
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   126
function test7() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   127
    var e = new Error("no message");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   128
    var i = 3;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   129
    try {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   130
        throw e;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   131
    } catch (ex) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   132
    } finally {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   133
        i++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   134
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   135
    if (i != 4) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 16151
diff changeset
   136
    print("FAIL");
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   137
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   138
    print("SUCCESS");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   139
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   140
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   141
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
test1();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
test2();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
print(test3());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   145
test4();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   146
print(test5())
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   147
test6();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   148
test7();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   149