stryker
Version:
The extendable JavaScript mutation testing framework
41 lines • 2.18 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var LocationHelper = /** @class */ (function () {
function LocationHelper(loc) {
this.loc = loc;
}
/**
* Indicates whether the current location is covered by an other location.
* @param maybeWrapper The location that is questioned to be wrapping this location.
* @returns true if this location is covered by given location, otherwise false
*/
LocationHelper.prototype.isCoveredBy = function (maybeWrapper) {
var isAfterStart = this.loc.start.line > maybeWrapper.start.line ||
(this.loc.start.line === maybeWrapper.start.line && this.loc.start.column >= maybeWrapper.start.column);
var isBeforeEnd = this.loc.end.line < maybeWrapper.end.line ||
(this.loc.end.line === maybeWrapper.end.line && this.loc.end.column <= maybeWrapper.end.column);
return isAfterStart && isBeforeEnd;
};
/**
* Indicates whether the given location is smaller than this location.
* @param maybeSmaller The area which is questioned to cover a smaller area than this location.
* @returns true if the given location covers a smaller area than this one.
*/
LocationHelper.prototype.isSmallerArea = function (maybeSmaller) {
var firstLocationHasSmallerArea = false;
var lineDifference = (this.loc.end.line - this.loc.start.line) - (maybeSmaller.end.line - maybeSmaller.start.line);
var coversLessLines = lineDifference > 0;
var coversLessColumns = lineDifference === 0 && (maybeSmaller.start.column - this.loc.start.column) + (this.loc.end.column - maybeSmaller.end.column) > 0;
if (coversLessLines || coversLessColumns) {
firstLocationHasSmallerArea = true;
}
return firstLocationHasSmallerArea;
};
LocationHelper.MAX_VALUE = new LocationHelper(Object.freeze({
end: Object.freeze({ column: Number.POSITIVE_INFINITY, line: Number.POSITIVE_INFINITY }),
start: Object.freeze({ column: 0, line: -1 })
}));
return LocationHelper;
}());
exports.default = LocationHelper;
//# sourceMappingURL=LocationHelper.js.map
;