tor-browser

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

array-rest-iter-thrw-close-skip.js (1510B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/dstr-assignment/array-rest-iter-thrw-close-skip.case
      3 // - src/dstr-assignment/error/assignment-expr.template
      4 /*---
      5 description: IteratorClose is not called when iteration produces an abrupt completion (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 : [ Elisionopt AssignmentRestElement ]
     19 
     20    [...]
     21    5. Let result be the result of performing
     22       IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
     23       iteratorRecord as the argument
     24    6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
     25       result).
     26 
     27 ---*/
     28 var nextCount = 0;
     29 var returnCount = 0;
     30 var x;
     31 var iterable = {};
     32 var iterator = {
     33  next: function() {
     34    nextCount += 1;
     35    throw new Test262Error();
     36  },
     37  return: function() {
     38    returnCount += 1;
     39  }
     40 };
     41 iterable[Symbol.iterator] = function() {
     42  return iterator;
     43 };
     44 
     45 assert.throws(Test262Error, function() {
     46  0, [...x] = iterable;
     47 });
     48 
     49 assert.sameValue(nextCount, 1);
     50 assert.sameValue(returnCount, 0);
     51 
     52 reportCompare(0, 0);