in-rltn-expr.js (1459B)
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-generator-function-definitions 5 es6id: 14.4 6 description: > 7 YieldExpression contextually recognizes the `in` keyword as part of a 8 RelationalExpression 9 info: | 10 Syntax 11 12 yield [no LineTerminator here] AssignmentExpression[?In, +Yield] 13 features: [generators] 14 ---*/ 15 16 var obj = Object.create(null); 17 var iter, iterResult, value; 18 function* g() { 19 value = yield 'hit' in obj; 20 value = yield 'miss' in obj; 21 } 22 obj.hit = true; 23 24 iter = g(); 25 26 iterResult = iter.next('first'); 27 28 assert.sameValue(iterResult.done, false, '`done` property (first iteration)'); 29 assert.sameValue(iterResult.value, true, '`value` property (first iteration)'); 30 assert.sameValue( 31 value, undefined, 'generator paused prior to evaluating AssignmentExpression' 32 ); 33 34 iterResult = iter.next('second'); 35 36 assert.sameValue(iterResult.done, false, '`done` property (second iteration)'); 37 assert.sameValue( 38 iterResult.value, false, '`value` property (second iteration)' 39 ); 40 assert.sameValue(value, 'second', 'value of first AssignmentExpression'); 41 42 iterResult = iter.next('third'); 43 44 assert.sameValue(iterResult.done, true, '`done` property (third iteration)'); 45 assert.sameValue( 46 iterResult.value, undefined, '`value` property (third iteration)' 47 ); 48 assert.sameValue(value, 'third', 'value of second AssignmentExpression'); 49 50 reportCompare(0, 0);