File: yield-as-statement.js

package info (click to toggle)
qtdeclarative-opensource-src-gles 5.15.17%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 258,992 kB
  • sloc: javascript: 512,415; cpp: 497,385; xml: 8,892; python: 3,304; ansic: 2,764; sh: 206; makefile: 46; php: 27
file content (47 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2013 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
  description: >
      `yield` is a valid statement within generator function bodies.
  features: [generators]
  es6id: 14.4
 ---*/

var iter, result;
var obj = {
  *g1() { yield; },
  *g2() { yield 1; }
};

iter = obj.g1();
result = iter.next();
assert.sameValue(
  result.value, undefined, 'Without right-hand-side: first result `value`'
);
assert.sameValue(
  result.done, false, 'Without right-hand-side: first result `done` flag'
);
result = iter.next();
assert.sameValue(
  result.value, undefined, 'Without right-hand-side: second result `value`'
);
assert.sameValue(
  result.done, true, 'Without right-hand-eside: second result `done` flag'
);

iter = obj.g2();
result = iter.next();
assert.sameValue(
  result.value, 1, 'With right-hand-side: first result `value`'
);
assert.sameValue(
  result.done, false, 'With right-hand-side: first result `done` flag'
);
result = iter.next();
assert.sameValue(
  result.value, undefined, 'With right-hand-side: second result `value`'
);
assert.sameValue(
  result.done, true, 'With right-hand-eside: second result `done` flag'
);