tor-browser

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

instance-length.js (1546B)


      1 // Copyright (C) 2018 Valerie Young. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-asyncgeneratorfunction
      5 description: Definition of instance `length` property
      6 info: |
      7    AsyncGeneratorFunction ( p1, p2, … , pn, body )
      8    ...
      9    3. Return CreateDynamicFunction(C, NewTarget, "async generator", args).
     10 
     11    Runtime Semantics: CreateDynamicFunction
     12    ...
     13    // the parameter "args" is sliced into "parameters" and "body"
     14    26. Perform FunctionInitialize(F, Normal, parameters, body, scope).
     15    ...
     16 
     17    FunctionInitialize
     18    ...
     19    2. Let len be the ExpectedArgumentCount of ParameterList.
     20    3. Perform ! DefinePropertyOrThrow(F, "length",
     21       PropertyDescriptor{[[Value]]: len, [[Writable]]: false, [[Enumerable]]:
     22       false, [[Configurable]]: true}).
     23    ...
     24 includes: [propertyHelper.js]
     25 features: [async-iteration]
     26 ---*/
     27 
     28 var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor;
     29 
     30 var instance = AsyncGeneratorFunction()
     31 
     32 verifyProperty(AsyncGeneratorFunction(), "length", {
     33  value: 0,
     34  enumerable: false,
     35  writable: false,
     36  configurable: true,
     37 });
     38 
     39 assert.sameValue(AsyncGeneratorFunction('').length, 0, "test 1");
     40 assert.sameValue(AsyncGeneratorFunction('x').length, 0, "test 2");
     41 assert.sameValue(AsyncGeneratorFunction('x', '').length, 1, "test 3");
     42 assert.sameValue(AsyncGeneratorFunction('x', 'y', '').length, 2, "test 4");
     43 assert.sameValue(AsyncGeneratorFunction('x, y', '').length, 2, "test 5");
     44 
     45 
     46 
     47 reportCompare(0, 0);