test/script/basic/es6/for-let-object-fields.js

Thu, 09 Mar 2017 10:25:09 -0800

author
asaha
date
Thu, 09 Mar 2017 10:25:09 -0800
changeset 2149
7355caa4e6cb
parent 1127
ec1fd6967009
permissions
-rw-r--r--

Merge

hannesw@1127 1 /*
hannesw@1127 2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
hannesw@1127 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1127 4 *
hannesw@1127 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1127 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1127 7 * published by the Free Software Foundation.
hannesw@1127 8 *
hannesw@1127 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1127 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1127 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1127 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1127 13 * accompanied this code).
hannesw@1127 14 *
hannesw@1127 15 * You should have received a copy of the GNU General Public License version
hannesw@1127 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1127 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1127 18 *
hannesw@1127 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1127 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1127 21 * questions.
hannesw@1127 22 */
hannesw@1127 23
hannesw@1127 24 /**
hannesw@1127 25 * JDK-8067219: NPE in ScriptObject.clone() when running with object fields
hannesw@1127 26 *
hannesw@1127 27 * @test
hannesw@1127 28 * @run
hannesw@1127 29 * @fork
hannesw@1127 30 * @option -Dnashorn.fields.objects=true
hannesw@1127 31 * @option --language=es6
hannesw@1127 32 */
hannesw@1127 33
hannesw@1127 34 "use strict";
hannesw@1127 35
hannesw@1127 36 for (let i = 0; i < 10; i++) {
hannesw@1127 37 print(i);
hannesw@1127 38 }
hannesw@1127 39
hannesw@1127 40 try {
hannesw@1127 41 print(i);
hannesw@1127 42 } catch (e) {
hannesw@1127 43 print(e);
hannesw@1127 44 }
hannesw@1127 45
hannesw@1127 46 let a = [];
hannesw@1127 47
hannesw@1127 48 for (let i = 0; i < 10; i++) {
hannesw@1127 49 a.push(function() { print(i); });
hannesw@1127 50 }
hannesw@1127 51
hannesw@1127 52 a.forEach(function(f) { f(); });
hannesw@1127 53
hannesw@1127 54 a = [];
hannesw@1127 55
hannesw@1127 56 for (let i = 0; i < 10; i++) {
hannesw@1127 57 if (i == 5) {
hannesw@1127 58 i = "foo";
hannesw@1127 59 }
hannesw@1127 60 a.push(function() { print(i); });
hannesw@1127 61 }
hannesw@1127 62
hannesw@1127 63 a.forEach(function(f) { f(); });
hannesw@1127 64
hannesw@1127 65 try {
hannesw@1127 66 print(i);
hannesw@1127 67 } catch (e) {
hannesw@1127 68 print(e);
hannesw@1127 69 }
hannesw@1127 70
hannesw@1127 71 a = [];
hannesw@1127 72
hannesw@1127 73 for (let i = 0; i < 20; i++) {
hannesw@1127 74 if (i % 2 == 1) {
hannesw@1127 75 i += 2;
hannesw@1127 76 continue;
hannesw@1127 77 }
hannesw@1127 78 a.push(function() { print(i); });
hannesw@1127 79 }
hannesw@1127 80
hannesw@1127 81 a.forEach(function(f) { f(); });

mercurial