mirror of
				https://github.com/tc39/test262.git
				synced 2025-11-04 13:44:29 +01:00 
			
		
		
		
	* Improve tests for GeneratorPrototype methods - Assert return values more consistently - Expand tests for constraints on `this` value * Add more tests for dynamic GeneratorFunctions * Add more tests for GenerationFunction.prototype * Add more tests for the GeneratorFunction object * Extend test: GeneratorFunction.prototype.prototype * Improve precision of tests for generator methods Extend existing assertions to explicitly verify that execution halts at the intended location. Correct tests which were previously asserting this behavior in contexts that did not match their name/description. * Remove unused variables * fixup! Improve tests for GeneratorPrototype methods * fixup! Improve tests for GeneratorPrototype methods
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
// Copyright (C) Copyright 2016 the V8 project authors. All rights reserved.
 | 
						|
// This code is governed by the BSD license found in the LICENSE file.
 | 
						|
/*---
 | 
						|
esid: sec-generatorfunction
 | 
						|
es6id: 25.2.1.1
 | 
						|
description: Definition of instance `length` property
 | 
						|
info: |
 | 
						|
    [...]
 | 
						|
    3. Return CreateDynamicFunction(C, NewTarget, "generator", args).
 | 
						|
 | 
						|
    19.2.1.1.1 Runtime Semantics: CreateDynamicFunction
 | 
						|
 | 
						|
    [...]
 | 
						|
    26. Perform FunctionInitialize(F, Normal, parameters, body, scope).
 | 
						|
    [...]
 | 
						|
 | 
						|
    9.2.4 FunctionInitialize
 | 
						|
 | 
						|
    [...]
 | 
						|
    3. Perform ! DefinePropertyOrThrow(F, "length",
 | 
						|
       PropertyDescriptor{[[Value]]: len, [[Writable]]: false, [[Enumerable]]:
 | 
						|
       false, [[Configurable]]: true}).
 | 
						|
    [...]
 | 
						|
includes: [propertyHelper.js]
 | 
						|
---*/
 | 
						|
 | 
						|
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
 | 
						|
 | 
						|
assert.sameValue(GeneratorFunction().length, 0);
 | 
						|
assert.sameValue(GeneratorFunction('').length, 0);
 | 
						|
assert.sameValue(GeneratorFunction('x').length, 0);
 | 
						|
assert.sameValue(GeneratorFunction('x', '').length, 1);
 | 
						|
assert.sameValue(GeneratorFunction('x', 'y', '').length, 2);
 | 
						|
assert.sameValue(GeneratorFunction('x, y', '').length, 2);
 | 
						|
 | 
						|
verifyNotEnumerable(GeneratorFunction(), 'length');
 | 
						|
verifyNotWritable(GeneratorFunction(), 'length');
 | 
						|
verifyConfigurable(GeneratorFunction(), 'length');
 |