Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

source-coverage.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.SourceCoverage = void 0;
  6. var _istanbulLibCoverage = require("istanbul-lib-coverage");
  7. function cloneLocation(loc) {
  8. return {
  9. start: {
  10. line: loc && loc.start.line,
  11. column: loc && loc.start.column
  12. },
  13. end: {
  14. line: loc && loc.end.line,
  15. column: loc && loc.end.column
  16. }
  17. };
  18. }
  19. /**
  20. * SourceCoverage provides mutation methods to manipulate the structure of
  21. * a file coverage object. Used by the instrumenter to create a full coverage
  22. * object for a file incrementally.
  23. *
  24. * @private
  25. * @param pathOrObj {String|Object} - see the argument for {@link FileCoverage}
  26. * @extends FileCoverage
  27. * @constructor
  28. */
  29. class SourceCoverage extends _istanbulLibCoverage.classes.FileCoverage {
  30. constructor(pathOrObj) {
  31. super(pathOrObj);
  32. this.meta = {
  33. last: {
  34. s: 0,
  35. f: 0,
  36. b: 0
  37. }
  38. };
  39. }
  40. newStatement(loc) {
  41. const s = this.meta.last.s;
  42. this.data.statementMap[s] = cloneLocation(loc);
  43. this.data.s[s] = 0;
  44. this.meta.last.s += 1;
  45. return s;
  46. }
  47. newFunction(name, decl, loc) {
  48. const f = this.meta.last.f;
  49. name = name || '(anonymous_' + f + ')';
  50. this.data.fnMap[f] = {
  51. name,
  52. decl: cloneLocation(decl),
  53. loc: cloneLocation(loc),
  54. // DEPRECATED: some legacy reports require this info.
  55. line: loc && loc.start.line
  56. };
  57. this.data.f[f] = 0;
  58. this.meta.last.f += 1;
  59. return f;
  60. }
  61. newBranch(type, loc) {
  62. const b = this.meta.last.b;
  63. this.data.b[b] = [];
  64. this.data.branchMap[b] = {
  65. loc: cloneLocation(loc),
  66. type,
  67. locations: [],
  68. // DEPRECATED: some legacy reports require this info.
  69. line: loc && loc.start.line
  70. };
  71. this.meta.last.b += 1;
  72. return b;
  73. }
  74. addBranchPath(name, location) {
  75. const bMeta = this.data.branchMap[name];
  76. const counts = this.data.b[name];
  77. /* istanbul ignore if: paranoid check */
  78. if (!bMeta) {
  79. throw new Error('Invalid branch ' + name);
  80. }
  81. bMeta.locations.push(cloneLocation(location));
  82. counts.push(0);
  83. return counts.length - 1;
  84. }
  85. /**
  86. * Assigns an input source map to the coverage that can be used
  87. * to remap the coverage output to the original source
  88. * @param sourceMap {object} the source map
  89. */
  90. inputSourceMap(sourceMap) {
  91. this.data.inputSourceMap = sourceMap;
  92. }
  93. freeze() {
  94. // prune empty branches
  95. const map = this.data.branchMap;
  96. const branches = this.data.b;
  97. Object.keys(map).forEach(b => {
  98. if (map[b].locations.length === 0) {
  99. delete map[b];
  100. delete branches[b];
  101. }
  102. });
  103. }
  104. }
  105. exports.SourceCoverage = SourceCoverage;