nashorn/test/script/basic/NASHORN-19.js
author hannesw
Fri, 03 May 2013 22:48:53 +0200
changeset 17521 0522325da5ef
parent 16151 97c1e756ae1e
child 24778 2ff5d7041566
permissions -rw-r--r--
8013873: Regexp regression for escaped dash in character class Reviewed-by: jlaskey
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.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
 * 
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.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
 * 
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).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
 * 
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.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
 * 
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-19:  with blocks in various scopes and breaking from them if they are inloops
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
 * (also continues)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
 * @test
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
 * @run
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    30
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    33
var myvalue = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    35
var myscope = {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
    myvalue: 11
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    37
};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    38
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    39
do {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    40
    with(myscope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    41
	myvalue = 12;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
	break;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    44
} while (false);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    46
if (myvalue != 'hello') {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
    throw "expecting to be hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
} else {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
    print("value is 'hello' as expected");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    50
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    51
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
function ten() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    55
    return 0xa;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    56
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    57
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    58
//make sure the scope works outside functions too
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    59
print("starting 0");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    60
var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
var scope2 = {value:20};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
while (true) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
    with (scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    65
	print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    66
	value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    67
	print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    68
	with (scope2) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    69
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    70
	    value = 21;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    72
	    break;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    73
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    74
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    75
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    76
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    77
print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    78
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    79
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
//two level scope
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    81
function test1() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    83
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
    var scope2 = {value:20};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
    while (true) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
	with (scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
	    value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    90
	    with (scope2) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    91
		print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    92
		value = 21;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    93
		print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    94
		break;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    95
	    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    96
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    97
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    98
    
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    99
    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   100
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   101
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   102
//one level scope
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   103
function test2() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   104
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   105
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   106
    while (true) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   107
	with (scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   108
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   109
	    value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   110
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   111
	    if (value > ten()) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   112
		break;
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
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   116
    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   117
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   118
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   119
//continue two levels
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   120
function test3() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   121
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   122
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   123
    var scope2 = {value:20};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   124
    var outer = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   125
    while (outer < 5) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   126
	var i=0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   127
	while (i < 10) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   128
	    with(scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   129
		print("loop header "+i);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   130
		with (scope2) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   131
		    value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   132
		    i++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   133
		    if ((i & 1) != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   134
			print("continue");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   135
			continue;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   136
		    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   137
		}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   138
	    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   139
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   140
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   141
	outer++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
} 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   145
//continue one level
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   146
function test4() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   147
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   148
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   149
    var i=0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   150
    while (i < 10) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   151
	print("loop header "+i);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   152
	with (scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   153
	    value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
	    i++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
	    if ((i & 1) != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   156
		print("continue");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   157
		continue;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   158
	    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   159
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   160
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   161
    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   162
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   163
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   164
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   165
//labelled continue;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   166
function test5() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   167
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
    var scope2 = {value:20};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   170
    var outer = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   171
    outer_label:
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   172
    while (outer < 5) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
	var i=0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
	while (i < 10) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
	    with(scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
		print("loop header "+i);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   177
		with (scope2) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
		    value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
		    i++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
		    if ((i & 1) != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
			print("continue");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   182
			outer++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
			continue outer_label;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   184
		    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
		}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
	    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   187
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
} 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
//labelled break
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   193
function test6() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   194
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   195
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   196
    var scope2 = {value:20};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
    outer:
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   198
    {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   199
	var i=0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   200
	while (i < 10) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   201
	    with(scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   202
		print("loop header "+i);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   203
		with (scope2) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   204
		    value = 11;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   205
		    i++;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   206
		    if ((i & 1) != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   207
			print("break");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   208
			break outer;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   209
		    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   210
		}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   211
	    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   212
	    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   213
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   214
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   215
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   216
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   217
//exceptions in one scope and then the other
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   218
function test7() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   219
    var value = "hello";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   220
    var scope = {value:10};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   221
    var scope2 = {value:20};    
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   222
    var global = false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   223
    try {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   224
	with(scope) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   225
	    try {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   226
		print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   227
		value = 4711;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   228
		print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   229
		with(scope2) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   230
		    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   231
		    value = 17;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   232
		    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   233
		    global = true;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   234
		    throw "inner";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   235
		}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   236
	    } catch (ei) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   237
		print(ei);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   238
		print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   239
		if (global) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   240
		    throw "outer";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   241
		}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   242
	    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   243
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   244
    } catch (eo) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   245
	print(eo);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   246
	print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   247
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   248
    print(value);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   249
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   250
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   251
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   252
print("starting 1");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   253
test1();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   254
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   255
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   256
print("starting 2");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   257
test2();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   258
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   259
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   260
print("starting 3");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   261
test3();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   262
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   263
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   264
print("starting 4");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   265
test4();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   266
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   267
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   268
print("starting 5");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   269
test5();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   270
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   271
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   272
print("starting 6");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   273
test6();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   274
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   275
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   276
print("starting 7");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   277
test7();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   278
print("\n");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   279