tor-browser

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

array-elem-trlg-iter-elision-iter-nrml-close-skip.js (1716B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-skip.case
      3 // - src/dstr-assignment/default/assignment-expr.template
      4 /*---
      5 description: IteratorClose not invoked when elision exhausts the iterator (AssignmentExpression)
      6 esid: sec-variable-statement-runtime-semantics-evaluation
      7 features: [Symbol.iterator, destructuring-binding]
      8 flags: [generated]
      9 info: |
     10    VariableDeclaration : BindingPattern Initializer
     11 
     12    1. Let rhs be the result of evaluating Initializer.
     13    2. Let rval be GetValue(rhs).
     14    3. ReturnIfAbrupt(rval).
     15    4. Return the result of performing BindingInitialization for
     16       BindingPattern passing rval and undefined as arguments.
     17 
     18    ArrayAssignmentPattern :
     19        [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
     20 
     21    [...]
     22    6. If Elision is present, then
     23       a. Let status be the result of performing
     24          IteratorDestructuringAssignmentEvaluation of Elision with
     25          iteratorRecord as the argument.
     26       b. If status is an abrupt completion, then
     27          [...]
     28    8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
     29       status).
     30    9. Return Completion(status).
     31 
     32 ---*/
     33 var nextCount = 0;
     34 var returnCount = 0;
     35 var iterable = {};
     36 var x;
     37 var iterator = {
     38  next: function() {
     39    nextCount += 1;
     40 
     41    return { done: nextCount > 1 };
     42  },
     43  return: function() {
     44    returnCount += 1;
     45  }
     46 };
     47 iterable[Symbol.iterator] = function() {
     48  return iterator;
     49 };
     50 
     51 var result;
     52 var vals = iterable;
     53 
     54 result = [ x , , ] = vals;
     55 
     56 assert.sameValue(nextCount, 2);
     57 assert.sameValue(returnCount, 0);
     58 
     59 assert.sameValue(result, vals);
     60 
     61 reportCompare(0, 0);