tor-browser

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

computed-name-toprimitive-symbol.js (3260B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/computed-name-toprimitive-symbol.case
      3 // - src/class-elements/default/cls-decl.template
      4 /*---
      5 description: ToPrimitive evaluation in the ComputedPropertyName (field definitions in a class declaration)
      6 esid: prod-FieldDefinition
      7 features: [class-fields-public, computed-property-names, Symbol.toPrimitive, Symbol, class]
      8 flags: [generated]
      9 includes: [propertyHelper.js]
     10 info: |
     11    Runtime Semantics: ClassDefinitionEvaluation
     12 
     13    ...
     14    27. For each ClassElement e in order from elements
     15      a. If IsStatic of me is false, then
     16        i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
     17      b. Else,
     18        i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
     19      c. If fields is an abrupt completion, then
     20        i. Set the running execution context's LexicalEnvironment to lex.
     21        ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
     22        iii. Return Completion(status).
     23    ...
     24 
     25    Runtime Semantics: ClassElementEvaluation
     26 
     27    ClassElement: FieldDefinition;
     28      Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
     29 
     30    Runtime Semantics: ClassFieldDefinitionEvaluation
     31      With parameters isStatic and homeObject.
     32 
     33    1. Let fieldName be the result of evaluating ClassElementName.
     34    2. ReturnIfAbrupt(fieldName).
     35    ...
     36 
     37    Runtime Semantics: Evaluation
     38      ComputedPropertyName: [ AssignmentExpression ]
     39 
     40    1. Let exprValue be the result of evaluating AssignmentExpression.
     41    2. Let propName be ? GetValue(exprValue).
     42    3. Return ? ToPropertyKey(propName).
     43 
     44 ---*/
     45 var s1 = Symbol();
     46 var s2 = Symbol();
     47 var s3 = Symbol();
     48 var err = function() { throw new Test262Error(); };
     49 var obj1 = {
     50  [Symbol.toPrimitive]: function() { return s1; },
     51  toString: err,
     52  valueOf: err
     53 };
     54 
     55 var obj2 = {
     56  toString: function() { return s2; },
     57  valueOf: err
     58 };
     59 
     60 var obj3 = {
     61  toString: undefined,
     62  valueOf: function() { return s3; }
     63 };
     64 
     65 
     66 
     67 class C {
     68  [obj1] = 42;
     69  [obj2] = 43;
     70  [obj3] = 44;
     71 }
     72 
     73 var c = new C();
     74 
     75 assert(
     76  !Object.prototype.hasOwnProperty.call(C.prototype, s1),
     77  "s1 doesn't appear as an own property on C prototype"
     78 );
     79 assert(
     80  !Object.prototype.hasOwnProperty.call(C, s1),
     81  "s1 doesn't appear as an own property on C constructor"
     82 );
     83 
     84 verifyProperty(c, s1, {
     85  value: 42,
     86  enumerable: true,
     87  writable: true,
     88  configurable: true
     89 });
     90 
     91 assert(
     92  !Object.prototype.hasOwnProperty.call(C.prototype, s2),
     93  "s2 doesn't appear as an own property on C prototype"
     94 );
     95 assert(
     96  !Object.prototype.hasOwnProperty.call(C, s2),
     97  "s2 doesn't appear as an own property on C constructor"
     98 );
     99 
    100 verifyProperty(c, s2, {
    101  value: 43,
    102  enumerable: true,
    103  writable: true,
    104  configurable: true
    105 });
    106 
    107 assert(
    108  !Object.prototype.hasOwnProperty.call(C.prototype, s3),
    109  "s3 doesn't appear as an own property on C prototype"
    110 );
    111 assert(
    112  !Object.prototype.hasOwnProperty.call(C, s3),
    113  "s3 doesn't appear as an own property on C constructor"
    114 );
    115 
    116 verifyProperty(c, s3, {
    117  value: 44,
    118  enumerable: true,
    119  writable: true,
    120  configurable: true
    121 });
    122 
    123 reportCompare(0, 0);