NASHORN-285.js revision 2:da1e581c933b
1204076Spjd/*
2204076Spjd * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
3210886Spjd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4204076Spjd *
5204076Spjd * This code is free software; you can redistribute it and/or modify it
6204076Spjd * under the terms of the GNU General Public License version 2 only, as
7204076Spjd * published by the Free Software Foundation.
8204076Spjd *
9204076Spjd * This code is distributed in the hope that it will be useful, but WITHOUT
10204076Spjd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11204076Spjd * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12204076Spjd * version 2 for more details (a copy is included in the LICENSE file that
13204076Spjd * accompanied this code).
14204076Spjd *
15204076Spjd * You should have received a copy of the GNU General Public License version
16204076Spjd * 2 along with this work; if not, write to the Free Software Foundation,
17204076Spjd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18204076Spjd *
19204076Spjd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20204076Spjd * or visit www.oracle.com if you need additional information or have any
21204076Spjd * questions.
22204076Spjd */
23204076Spjd
24204076Spjd/**
25204076Spjd * NASHORN-258 : loops with continues could be marked terminal
26204076Spjd *
27204076Spjd * @test
28204076Spjd * @run
29204076Spjd */
30204076Spjd
31204076Spjdfunction do_not_loop_forever() {
32204076Spjd    var sum = 0;
33204076Spjd    for (var i = 0; i < 4711; i++) {
34204076Spjd	sum += i;
35204076Spjd	if (i >= 0) {
36204076Spjd            continue;
37204076Spjd        }
38204076Spjd	return sum;
39204076Spjd    }
40204076Spjd    return sum;
41204076Spjd}
42204076Spjd
43204076Spjd
44204076Spjdfunction still_tag_terminal() {
45204076Spjd    var sum = 0;
46204076Spjd    for (var i = 0; i < 4711; i++) {
47204076Spjd	sum += i;
48204076Spjd	for (var j = 0; j < 4712; j++) {
49211982Spjd	    sum += j;
50204076Spjd	    if (j & 1) {
51204076Spjd		continue;
52204076Spjd	    }
53204076Spjd	}
54204076Spjd	return sum;
55204076Spjd    }
56204076Spjd    return sum;
57204076Spjd}
58204076Spjd
59204076Spjdprint(do_not_loop_forever());
60204076Spjdprint(still_tag_terminal());
61212038Spjd