tor-browser

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

array-elem-trlg-iter-rest-thrw-close-skip.js (1814B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/dstr-assignment/array-elem-trlg-iter-rest-thrw-close-skip.case
      3 // - src/dstr-assignment/error/assignment-expr.template
      4 /*---
      5 description: Abrupt completion returned during iteration for rest element (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    7. If AssignmentRestElement is present, then
     23       a. Let status be the result of performing
     24          IteratorDestructuringAssignmentEvaluation of AssignmentRestElement
     25          with iteratorRecord as the argument.
     26    8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
     27       status).
     28    9. Return Completion(status).
     29 
     30 ---*/
     31 var nextCount = 0;
     32 var returnCount = 0;
     33 var iterable = {};
     34 var x;
     35 var iterator = {
     36  next: function() {
     37    nextCount += 1;
     38 
     39    if (nextCount === 2) {
     40      throw new Test262Error();
     41    }
     42 
     43    // Set an upper-bound to limit unnecessary iteration in non-conformant
     44    // implementations
     45    return { done: nextCount > 10 };
     46  },
     47  return: function() {
     48    returnCount += 1;
     49  }
     50 };
     51 iterable[Symbol.iterator] = function() {
     52  return iterator;
     53 };
     54 
     55 assert.throws(Test262Error, function() {
     56  0, [ x , ...x ] = iterable;
     57 });
     58 
     59 assert.sameValue(nextCount, 2);
     60 assert.sameValue(returnCount, 0);
     61 
     62 reportCompare(0, 0);