tor-browser

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

yield-expr.js (1438B)


      1 // |reftest| async
      2 // Copyright (C) 2018 Leo Balter. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: >
      6    Dynamic Import receives an AssignmentExpression (YieldExpression)
      7 esid: prod-ImportCall
      8 info: |
      9    ImportCall [Yield]:
     10        import ( AssignmentExpression[+In, ?Yield] )
     11 
     12    AssignmentExpression[In, Yield, Await]:
     13        ConditionalExpression[?In, ?Yield, ?Await]
     14        [+Yield]YieldExpression[?In, ?Await]
     15        ArrowFunction[?In, ?Yield, ?Await]
     16        AsyncArrowFunction[?In, ?Yield, ?Await]
     17        LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await]
     18        LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await]
     19 flags: [async]
     20 features: [dynamic-import]
     21 includes: [asyncHelpers.js]
     22 ---*/
     23 
     24 const a = './module-code_FIXTURE.js';
     25 const b = './module-code-other_FIXTURE.js';
     26 
     27 function *g() {
     28    return import(yield);
     29 }
     30 
     31 async function fn() {
     32    let iter = g();
     33    iter.next();
     34 
     35    const ns1 = await iter.next(a).value; // import('./module-code_FIXTURE.js')
     36 
     37    assert.sameValue(ns1.local1, 'Test262');
     38    assert.sameValue(ns1.default, 42);
     39 
     40    iter = g();
     41    iter.next();
     42 
     43    const ns2 = await iter.next(b).value; // import('./module-code-other_FIXTURE.js')
     44 
     45    assert.sameValue(ns2.local1, 'one six one two');
     46    assert.sameValue(ns2.default, 1612);
     47 }
     48 
     49 asyncTest(fn);