tor-browser

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

private-static-method-name.js (2886B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/private-static-method-name.case
      3 // - src/class-elements/default/cls-expr.template
      4 /*---
      5 description: Private static methods have name property properly configured (field definitions in a class expression)
      6 esid: prod-FieldDefinition
      7 features: [class-static-methods-private, class]
      8 flags: [generated]
      9 info: |
     10    Updated Productions
     11 
     12    ClassElement : MethodDefinition
     13      1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
     14 
     15    ClassElement : static MethodDefinition
     16      1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
     17 
     18    MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
     19      1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
     20      2. ReturnIfAbrupt(methodDef).
     21      3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
     22 
     23    ClassElement : MethodDefinition
     24    ClassElement : static MethodDefinition
     25      1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
     26      2. Return empty.
     27 
     28    MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
     29      1. Let propKey be the result of evaluating ClassElementName.
     30      ...
     31      8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
     32      9. Perform MakeMethod(closure, object).
     33      10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
     34 
     35    ClassElementName : PrivateIdentifier
     36      1. Let bindingName be StringValue of PrivateIdentifier.
     37      ...
     38      5. If scopeEnvRec's binding for bindingName is uninitialized,
     39        a. Let field be NewPrivateName(bindingName).
     40        b. Perform ! scopeEnvRec.InitializeBinding(bindingName, field).
     41      6. Otherwise,
     42        a. Let field be scopeEnvRec.GetBindingValue(bindingName).
     43      7. Assert: field.[[Description]] is bindingName.
     44      8. Return field.
     45 
     46    DefineOrdinaryMethod(key, homeObject, closure, enumerable)
     47      1. Perform SetFunctionName(closure, key).
     48      2. If key is a Private Name,
     49        a. Assert: key does not have a [[Kind]] field.
     50        b. Set key.[[Kind]] to "method".
     51        c. Set key.[[Value]] to closure.
     52        d. Set key.[[Brand]] to homeObject.
     53      3. Else,
     54        a. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true}.
     55        b. Perform ? DefinePropertyOrThrow(homeObject, key, desc).
     56 
     57 ---*/
     58 
     59 
     60 var C = class {
     61  static #method() {
     62    return 'Test262';
     63  };
     64 
     65  static getPrivateMethod() {
     66    return this.#method;
     67  }
     68 
     69 }
     70 
     71 assert.sameValue(C.getPrivateMethod().name, "#method");
     72 
     73 reportCompare(0, 0);