tor-browser

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

rhs-regexp.js (1470B)


      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-generator-function-definitions
      5 es6id: 14.4
      6 description: >
      7  YieldExpression accepts a regular expression literal as its right-hand side
      8 info: |
      9  The syntactic context immediately following yield requires use of the
     10  InputElementRegExpOrTemplateTail lexical goal.
     11 features: [generators]
     12 ---*/
     13 
     14 var complete = false;
     15 var sent = {};
     16 var iter, iterResult, received;
     17 // Unused variables declared to improve error messages in incorrect parsing
     18 // scenarios.
     19 var abc, i;
     20 function* g() {
     21  received = yield/abc/i;
     22  complete = true;
     23 }
     24 
     25 iter = g();
     26 
     27 assert.sameValue(complete, false, 'generator initially paused');
     28 assert.sameValue(received, undefined, 'first statement no executed');
     29 
     30 iterResult = iter.next();
     31 
     32 assert.sameValue(complete, false, 'generator paused following expression');
     33 assert.sameValue(received, undefined, 'first statement not executed');
     34 
     35 assert.sameValue(iterResult.done, false, 'iteration not complete');
     36 assert.sameValue(iterResult.value.test('ABC'), true, 'first iterated value');
     37 
     38 iterResult = iter.next(sent);
     39 
     40 assert.sameValue(received, sent, 'YieldExpression value');
     41 assert.sameValue(complete, true, 'generator correctly re-started');
     42 assert.sameValue(iterResult.done, true, 'iteration complete');
     43 assert.sameValue(iterResult.value, undefined, 'second iterated value');
     44 
     45 reportCompare(0, 0);