1 /*
   2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * no_line_numbers.js - make sure that switching off line number generation
  26  * doesn't break. Otherwise, this is just NASHORN-73, a unit test particularly
  27  * prone to label bugs in CodeGenerator
  28  *
  29  * @test
  30  * @run
  31  * @option --debug-lines=false
  32  */
  33 
  34 print("x = " + x);
  35 do {
  36    break;
  37    var x;
  38 } while (true);
  39 
  40 
  41 print("y = " + y);
  42 while (true) {
  43     break;
  44     var y;
  45 }
  46 
  47 print("z = " + z);
  48 for ( ; ; ) {
  49    break;
  50    var z;
  51    print("THIS SHOULD NEVER BE PRINTED!");
  52 }
  53 
  54 while (true) {
  55     break;
  56     if (true) {
  57     var s;
  58     }
  59 }
  60 
  61 print("s = "+s);
  62 
  63 print("u = "+u);
  64 for ( ; ; ) {
  65     break;
  66     while (true) {
  67     do {
  68         var u;
  69     } while (true);
  70     }
  71 }
  72 
  73 function terminal() {
  74     print("r = "+r);
  75     print("t = "+t);
  76     for (;;) {
  77     var r;
  78     return;
  79     var t;
  80     print("THIS SHOULD NEVER BE PRINTED!");
  81     }
  82     print("NEITHER SHOULD THIS");
  83 }
  84 
  85 terminal();
  86 
  87 function terminal2() {
  88     print("q = "+q);
  89     for (;;) {
  90     return;
  91     print("THIS SHOULD NEVER BE PRINTED!");
  92     }
  93     print("NEITHER SHOULD THIS");
  94 }
  95 
  96 try {
  97     terminal2();
  98 } catch (e) {
  99     print(e);
 100 }
 101 
 102 function scope2() {
 103     var b = 10;
 104     print("b = "+b);
 105 }
 106 
 107 scope2();
 108 
 109 try {
 110     print("b is = "+b);
 111 }  catch (e) {
 112     print(e);
 113 }
 114 
 115 
 116 function disp_a() {
 117     var a = 20;
 118     print("Value of 'a' inside the function " + a);
 119 }
 120 
 121 var a = 10;
 122 
 123 disp_a();
 124 
 125 print("Value of 'a' outside the function " + a);