Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/yield/from-with.js

raw
1 // Copyright (C) 2013 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 25.2
5 description: >
6 The operand to a `yield` expression should honor the semantics of the
7 `with` statement.
8 flags: [noStrict]
9 features: [generators]
10 ---*/
11
12 function* g() {
13 var x = 1;
14
15 yield x;
16
17 with ({ x: 2 }) {
18 yield x;
19 }
20
21 yield x;
22 }
23 var iter = g();
24 var result;
25
26 result = iter.next();
27 assert.sameValue(result.value, 1, 'First result `value`');
28 assert.sameValue(result.done, false, 'First result `done` flag');
29
30 result = iter.next();
31 assert.sameValue(result.value, 2, 'Second result `value`');
32 assert.sameValue(result.done, false, 'Second result `done` flag');
33
34 result = iter.next();
35 assert.sameValue(result.value, 1, 'Third result `value`');
36 assert.sameValue(result.done, false, 'Third result `done` flag');
37
38 result = iter.next();
39 assert.sameValue(result.value, undefined, 'Final result `value`');
40 assert.sameValue(result.done, true, 'Final result `done` flag');