Debian Codegraph @

test/instrumentation/test-es6-forof.js

raw
1 /*jslint nomen: true */
2 var helper = require('../helper'),
3 code,
4 verifier;
5
6 /*jshint maxlen: 500 */
7 if (require('../es6').isForOfAvailable()) {
8 module.exports = {
9 "with a simple for-in": {
10 setUp: function (cb) {
11 code = [
12 'function *x() { yield 1; yield 2; };',
13 'var k;',
14 'output = 0;',
15 'for (k of x()) {',
16 ' output += k;',
17 '}'
18 ];
19 verifier = helper.verifier(__filename, code);
20 cb();
21 },
22
23 "should cover loop exactly once": function (test) {
24 verifier.verify(test, [], 3, { lines: { '1': 1, '2': 1, '3': 1, '4': 1, '5': 2 }, branches: {}, functions: { '1': 1 }, statements: { '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 1, '7': 2 } });
25 test.done();
26 }
27 },
28 "with a simple for-of declaring the loop initializer": {
29 setUp: function (cb) {
30 code = [
31 'function *x() { yield 1; yield 2; };',
32 'output = 0;',
33 'for (var k of x()) {',
34 ' output += k;',
35 '}'
36 ];
37 verifier = helper.verifier(__filename, code);
38 cb();
39 },
40
41 "should cover loop exactly once": function (test) {
42 verifier.verify(test, [], 3, { lines: { '1': 1, '2': 1, '3': 1, '4': 2 }, branches: {}, functions: { '1': 1 }, statements: { '1': 1, '2': 1, '3': 1, '4': 1, '5': 1, '6': 2 } });
43 test.done();
44 }
45 }
46 };
47 }
48