tor-browser

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

same-line-async-method-computed-symbol-names.js (3013B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/class-elements/computed-symbol-names.case
      4 // - src/class-elements/productions/cls-expr-after-same-line-async-method.template
      5 /*---
      6 description: Computed property symbol names (field definitions after an async method in the same line)
      7 esid: prod-FieldDefinition
      8 features: [class-fields-public, Symbol, computed-property-names, class, async-functions]
      9 flags: [generated, async]
     10 includes: [propertyHelper.js]
     11 info: |
     12    ClassElement:
     13      ...
     14      FieldDefinition ;
     15 
     16    FieldDefinition:
     17      ClassElementName Initializer_opt
     18 
     19    ClassElementName:
     20      PropertyName
     21 
     22 ---*/
     23 var x = Symbol();
     24 var y = Symbol();
     25 
     26 
     27 
     28 var C = class {
     29  async m() { return 42; } [x]; [y] = 42;
     30  
     31 }
     32 
     33 var c = new C();
     34 
     35 assert(
     36  !Object.prototype.hasOwnProperty.call(c, "m"),
     37  "m doesn't appear as an own property on the C instance"
     38 );
     39 assert.sameValue(c.m, C.prototype.m);
     40 
     41 verifyProperty(C.prototype, "m", {
     42  enumerable: false,
     43  configurable: true,
     44  writable: true,
     45 }, {restore: true});
     46 
     47 c.m().then(function(v) {
     48  assert.sameValue(v, 42);
     49 
     50  function assertions() {
     51    // Cover $DONE handler for async cases.
     52    function $DONE(error) {
     53      if (error) {
     54        throw new Test262Error('Test262:AsyncTestFailure')
     55      }
     56    }
     57    assert(
     58      !Object.prototype.hasOwnProperty.call(C.prototype, x),
     59      "Symbol x doesn't appear as an own property on C prototype"
     60    );
     61    assert(
     62      !Object.prototype.hasOwnProperty.call(C, x),
     63      "Symbol x doesn't appear as an own property on C constructor"
     64    );
     65 
     66    verifyProperty(c, x, {
     67      value: undefined,
     68      enumerable: true,
     69      writable: true,
     70      configurable: true
     71    });
     72 
     73    assert(
     74      !Object.prototype.hasOwnProperty.call(C.prototype, y),
     75      "Symbol y doesn't appear as an own property on C prototype"
     76    );
     77    assert(
     78      !Object.prototype.hasOwnProperty.call(C, y),
     79      "Symbol y doesn't appear as an own property on C constructor"
     80    );
     81 
     82    verifyProperty(c, y, {
     83      value: 42,
     84      enumerable: true,
     85      writable: true,
     86      configurable: true
     87    });
     88 
     89    assert(
     90      !Object.prototype.hasOwnProperty.call(C.prototype, "x"),
     91      "x doesn't appear as an own property on C prototype"
     92    );
     93    assert(
     94      !Object.prototype.hasOwnProperty.call(C, "x"),
     95      "x doesn't appear as an own property on C constructor"
     96    );
     97    assert(
     98      !Object.prototype.hasOwnProperty.call(c, "x"),
     99      "x doesn't appear as an own property on C instance"
    100    );
    101 
    102    assert(
    103      !Object.prototype.hasOwnProperty.call(C.prototype, "y"),
    104      "y doesn't appear as an own property on C prototype"
    105    );
    106    assert(
    107      !Object.prototype.hasOwnProperty.call(C, "y"),
    108      "y doesn't appear as an own property on C constructor"
    109    );
    110    assert(
    111      !Object.prototype.hasOwnProperty.call(c, "y"),
    112      "y doesn't appear as an own property on C instance"
    113    );
    114  }
    115 
    116  return Promise.resolve(assertions());
    117 }).then($DONE, $DONE);