tor-browser

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

private-method-length.js (1750B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/class-elements/private-method-length.case
      3 // - src/class-elements/default/cls-decl.template
      4 /*---
      5 description: Private methods have length property properly configured (field definitions in a class declaration)
      6 esid: prod-FieldDefinition
      7 features: [class-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      ...
     30      8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
     31      9. Perform MakeMethod(closure, object).
     32      10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
     33 
     34 ---*/
     35 
     36 
     37 class C {
     38  #method(a) {};
     39 
     40  getPrivateMethod() {
     41    return this.#method;
     42  }
     43 
     44 }
     45 
     46 let c = new C();
     47 assert.sameValue(c.getPrivateMethod().length, 1);
     48 
     49 reportCompare(0, 0);