Home | History | Annotate | Download | only in regress
      1 // Copyright 2015 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Flags: --harmony-do-expressions
      6 
      7 (function testWithSimpleLoopVariable() {
      8   var f = (x, y = (do { var s=0; for (var e of x) s += e; s; })) => y*(y+1);
      9   var result = f([1,2,3]);  // core dump here, if not fixed.
     10   assertEquals(result, 42);
     11 })();
     12 
     13 (function testWithComplexLoopVariable() {
     14   var f = (x, i=x[0]-1, a=[],
     15            y = (do { var s=0;
     16                      for (a[i] of x) s += a[i++];
     17                      s;
     18                    })) => y*(a[0]+a[1]*a[2]);
     19   var result = f([1,2,3]);  // core dump here, if not fixed.
     20   assertEquals(result, 42);
     21 })();
     22