regress-3683.js 1.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

"use strict";

// Simplest case
var count = 0;
for (let x = 0; x < 10;) {
  x++;
  count++;
  continue;
}
assertEquals(10, count);

// Labeled
count = 0;
label: for (let x = 0; x < 10;) {
  while (true) {
    x++;
    count++;
    continue label;
  }
}
assertEquals(10, count);

// Simple and labeled
count = 0;
label: for (let x = 0; x < 10;) {
  x++;
  count++;
  continue label;
}
assertEquals(10, count);

// Shadowing loop variable in same scope as continue
count = 0;
for (let x = 0; x < 10;) {
  x++;
  count++;
  {
    let x = "hello";
    continue;
  }
}
assertEquals(10, count);

// Nested let-bound for loops, inner continue
count = 0;
for (let x = 0; x < 10;) {
  x++;
  for (let y = 0; y < 2;) {
    y++;
    count++;
    continue;
  }
}
assertEquals(20, count);

// Nested let-bound for loops, outer continue
count = 0;
for (let x = 0; x < 10;) {
  x++;
  for (let y = 0; y < 2;) {
    y++;
    count++;
  }
  continue;
}
assertEquals(20, count);

// Nested let-bound for loops, labeled continue
count = 0;
outer: for (let x = 0; x < 10;) {
  x++;
  for (let y = 0; y < 2;) {
    y++;
    count++;
    if (y == 2) continue outer;
  }
}
assertEquals(20, count);