instance-length.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2016 the V8 project authors. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-generatorfunction
  5. description: Definition of instance `length` property
  6. info: |
  7. [...]
  8. 3. Return CreateDynamicFunction(C, NewTarget, "generator", args).
  9. 19.2.1.1.1 Runtime Semantics: CreateDynamicFunction
  10. [...]
  11. 26. Perform FunctionInitialize(F, Normal, parameters, body, scope).
  12. [...]
  13. 9.2.4 FunctionInitialize
  14. [...]
  15. 3. Perform ! DefinePropertyOrThrow(F, "length",
  16. PropertyDescriptor{[[Value]]: len, [[Writable]]: false, [[Enumerable]]:
  17. false, [[Configurable]]: true}).
  18. [...]
  19. includes: [propertyHelper.js]
  20. features: [generators]
  21. ---*/
  22. var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
  23. assert.sameValue(GeneratorFunction().length, 0);
  24. assert.sameValue(GeneratorFunction('').length, 0);
  25. assert.sameValue(GeneratorFunction('x').length, 0);
  26. assert.sameValue(GeneratorFunction('x', '').length, 1);
  27. assert.sameValue(GeneratorFunction('x', 'y', '').length, 2);
  28. assert.sameValue(GeneratorFunction('x, y', '').length, 2);
  29. verifyNotEnumerable(GeneratorFunction(), 'length');
  30. verifyNotWritable(GeneratorFunction(), 'length');
  31. verifyConfigurable(GeneratorFunction(), 'length');