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

Print this page




  22  */
  23 
  24 /**
  25  * JDK-8051889: Implement block scoping in symbol assignment and scope computation
  26  *
  27  * @test
  28  * @run
  29  * @option --language=es6 */
  30 
  31 "use strict";
  32 
  33 for (let i = 0; i < 10; i++) {
  34     print(i);
  35 }
  36 
  37 try {
  38     print(i);
  39 } catch (e) {
  40     print(e);
  41 }







































  22  */
  23 
  24 /**
  25  * JDK-8051889: Implement block scoping in symbol assignment and scope computation
  26  *
  27  * @test
  28  * @run
  29  * @option --language=es6 */
  30 
  31 "use strict";
  32 
  33 for (let i = 0; i < 10; i++) {
  34     print(i);
  35 }
  36 
  37 try {
  38     print(i);
  39 } catch (e) {
  40     print(e);
  41 }
  42 
  43 let a = [];
  44 
  45 for (let i = 0; i < 10; i++) {
  46     a.push(function() { print(i); });
  47 }
  48 
  49 a.forEach(function(f) { f(); });
  50 
  51 a = [];
  52 
  53 for (let i = 0; i < 10; i++) {
  54     if (i == 5) {
  55         i = "foo";
  56     }
  57     a.push(function() { print(i); });
  58 }
  59 
  60 a.forEach(function(f) { f(); });
  61 
  62 try {
  63     print(i);
  64 } catch (e) {
  65     print(e);
  66 }
  67 
  68 a = [];
  69 
  70 for (let i = 0; i < 20; i++) {
  71     if (i % 2 == 1) {
  72         i += 2;
  73         continue;
  74     }
  75     a.push(function() { print(i); });
  76 }
  77 
  78 a.forEach(function(f) { f(); });