tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nonstrict-initializer.js (998B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-initializers-in-forin-statement-heads
      5 description: >
      6    for-in initializers in nonstrict mode
      7 flags: [noStrict]
      8 ---*/
      9 (function() {
     10  var effects = 0;
     11  for (var a = ++effects in {});
     12  assert.sameValue(effects, 1);
     13 })();
     14 
     15 
     16 (function() {
     17  var stored;
     18  for (var a = 0 in stored = a, {});
     19  assert.sameValue(stored, 0);
     20 })();
     21 
     22 
     23 (function() {
     24  for (var a = 0 in {});
     25  assert.sameValue(a, 0);
     26 })();
     27 
     28 
     29 (function() {
     30  var effects = 0;
     31  var iterations = 0;
     32  var stored;
     33  for (var a = (++effects, -1) in stored = a, {a: 0, b: 1, c: 2}) {
     34    ++iterations;
     35  }
     36  assert.sameValue(stored, -1, "Initialized value should be available to RHS");
     37  assert.sameValue(effects, 1, "Initializer should only be executed once");
     38  assert.sameValue(iterations, 3, "Loop body should be executed the appropriate number of times");
     39 })();
     40 
     41 reportCompare(0, 0);