Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 1x 1x 1x 1x 1x 15x 20x 12x 12x 12x 12x 12x 12x 8x 4x 12x 15x 15x 3x 12x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x | "use strict";
/**
* Generator utils.
*
* @module
*/
var fs = require("fs");
var _ = require("lodash");
var U = require("glace-utils");
var yaml = require("js-yaml");
/**
* Defines whether step income is a part of test state.
*
* @function
* @arg {?object} dict - Test case state.
* @arg {?object} sub - Step income state.
* @return {boolean} `true` if it's a part, `false` otherwise.
*/
exports.isSub = (dict, sub) => {
var _isSub = (dict, sub) => {
var result;
for (var [k, v] of Object.entries(sub)) {
var val = dict[k];
if (v === true) v = {};
if (val === true) val = {};
Iif (!v) v = false;
if (!val) val = false;
if (_.isObject(v) && _.isObject(val)) {
result = _isSub(val, v);
} else {
result = val === v;
};
if (!result) return false;
};
return true;
};
if (!_.isObject(dict) || !_.isObject(sub)) {
return false;
};
return _isSub(dict, sub);
};
exports.getDups = arr => {
var dict = {}, dups =[];
for (var a of arr) {
Iif (dict[a]) {
if (!dups.includes(a)) dups.push(a);
} else {
dict[a] = true;
}
}
return dups;
};
/**
* Loads steps file.
*
* @ignore
* @function
* @arg {string} filePath
* @return {object[]}
*/
exports.loadFile = filePath => {
var data;
Eif (filePath.endsWith(".yml") || filePath.endsWith(".yaml")) {
data = yaml.safeLoad(fs.readFileSync(filePath, "utf8"));
} else {
data = U.loadJson(filePath);
};
return data;
};
|