@syntest/search
Advanced tools
Comparing version 0.4.0-beta.36 to 0.4.0-beta.37
@@ -35,2 +35,3 @@ "use strict"; | ||
} | ||
// eslint-disable-next-line sonarjs/cognitive-complexity | ||
calculateDistance(encoding) { | ||
@@ -90,7 +91,2 @@ const executionResult = encoding.getExecutionResult(); | ||
let branchDistance = this.branchDistance.calculate(closestCoveredBranchTrace.condition_ast, closestCoveredBranchTrace.condition, closestCoveredBranchTrace.variables, trueOrFalse); | ||
if (!(typeof branchDistance === "number" && Number.isFinite(branchDistance))) { | ||
// this is a dirty hack to prevent wrong branch distance numbers | ||
// in the future we need to simply fix the branch distance calculation and remove this | ||
branchDistance = 0.999; | ||
} | ||
if (Number.isNaN(approachLevel)) { | ||
@@ -105,2 +101,9 @@ throw new TypeError((0, diagnostics_1.shouldNeverHappen)("ObjectiveManager")); | ||
} | ||
if (branchDistance === 0 && approachLevel !== 0) { | ||
throw new Error((0, diagnostics_1.shouldNeverHappen)("ObjectiveManager")); | ||
} | ||
if (approachLevel + branchDistance === 0) { | ||
// TODO this is a hack to make sure a wrong branch distance calculation doesnt throw off the entire distance | ||
branchDistance += 0.999; | ||
} | ||
// add the distances | ||
@@ -107,0 +110,0 @@ return approachLevel + branchDistance; |
@@ -13,3 +13,3 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, encoding: T): void; | ||
protected _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, encoding: T): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -16,0 +16,0 @@ * @inheritdoc |
@@ -33,5 +33,6 @@ "use strict"; | ||
// Update the objectives | ||
this._updateObjectives(objectiveFunction); | ||
const childObjectives = this._updateObjectives(objectiveFunction); | ||
// Update the archive | ||
this._updateArchive(objectiveFunction, encoding); | ||
return childObjectives; | ||
} | ||
@@ -38,0 +39,0 @@ /** |
@@ -65,3 +65,3 @@ import { Logger } from "@syntest/logging"; | ||
*/ | ||
protected abstract _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, encoding: T): void; | ||
protected abstract _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, encoding: T): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -83,3 +83,3 @@ * Logic for handling uncovered objectives. | ||
*/ | ||
protected abstract _updateObjectives(objectiveFunction: ObjectiveFunction<T>): void; | ||
protected abstract _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -101,2 +101,3 @@ * Evaluate multiple encodings on the current objectives. | ||
evaluateOne(encoding: T, budgetManager: BudgetManager<T>, _terminationManager: TerminationManager): Promise<void>; | ||
protected evaluateObjective(encoding: T, objectiveFunction: ObjectiveFunction<T>): void; | ||
/** | ||
@@ -103,0 +104,0 @@ * Load the objectives from the search subject into the manager. |
@@ -80,17 +80,3 @@ "use strict"; | ||
for (const objectiveFunction of this._currentObjectives) { | ||
// Calculate and store the distance | ||
const distance = objectiveFunction.calculateDistance(encoding); | ||
if (Number.isNaN(distance)) { | ||
throw new TypeError((0, diagnostics_1.shouldNeverHappen)("ObjectiveManager")); | ||
} | ||
encoding.setDistance(objectiveFunction, distance); | ||
// When the objective is covered, update the objectives and the archive | ||
if (distance === 0) { | ||
ObjectiveManager.LOGGER.debug(`Objective ${objectiveFunction.getIdentifier()} covered by encoding ${encoding.id}`); | ||
this._handleCoveredObjective(objectiveFunction, encoding); | ||
} | ||
else { | ||
ObjectiveManager.LOGGER.debug(`Distance from objective ${objectiveFunction.getIdentifier()} is ${distance} for encoding ${encoding.id}`); | ||
this._handleUncoveredObjective(objectiveFunction, encoding, distance); | ||
} | ||
this.evaluateObjective(encoding, objectiveFunction); | ||
} | ||
@@ -115,2 +101,22 @@ // Create separate exception objective when an exception occurred in the execution | ||
} | ||
evaluateObjective(encoding, objectiveFunction) { | ||
// Calculate and store the distance | ||
const distance = objectiveFunction.calculateDistance(encoding); | ||
if (Number.isNaN(distance)) { | ||
throw new TypeError((0, diagnostics_1.shouldNeverHappen)("ObjectiveManager")); | ||
} | ||
encoding.setDistance(objectiveFunction, distance); | ||
// When the objective is covered, update the objectives and the archive | ||
if (distance === 0) { | ||
ObjectiveManager.LOGGER.debug(`Objective ${objectiveFunction.getIdentifier()} covered by encoding ${encoding.id}`); | ||
const newObjectives = this._handleCoveredObjective(objectiveFunction, encoding); | ||
for (const objective of newObjectives) { | ||
this.evaluateObjective(encoding, objective); | ||
} | ||
} | ||
else { | ||
ObjectiveManager.LOGGER.debug(`Distance from objective ${objectiveFunction.getIdentifier()} is ${distance} for encoding ${encoding.id}`); | ||
this._handleUncoveredObjective(objectiveFunction, encoding, distance); | ||
} | ||
} | ||
/** | ||
@@ -117,0 +123,0 @@ * Reset the objectives. |
@@ -13,3 +13,3 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, _encoding: T): void; | ||
protected _handleCoveredObjective(objectiveFunction: ObjectiveFunction<T>, _encoding: T): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -16,0 +16,0 @@ * @inheritdoc |
@@ -33,3 +33,3 @@ "use strict"; | ||
// Update the objectives | ||
this._updateObjectives(objectiveFunction); | ||
return this._updateObjectives(objectiveFunction); | ||
} | ||
@@ -36,0 +36,0 @@ /** |
@@ -21,3 +21,3 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): void; | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -24,0 +24,0 @@ * @inheritDoc |
@@ -47,2 +47,3 @@ "use strict"; | ||
this._coveredObjectives.add(objectiveFunction); | ||
return []; | ||
} | ||
@@ -49,0 +50,0 @@ /** |
@@ -15,3 +15,3 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): void; | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -18,0 +18,0 @@ * @inheritDoc |
@@ -51,2 +51,3 @@ "use strict"; | ||
} | ||
return []; | ||
} | ||
@@ -53,0 +54,0 @@ /** |
@@ -14,4 +14,4 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): void; | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; | ||
} | ||
//# sourceMappingURL=StructuralUncoveredObjectiveManager.d.ts.map |
@@ -42,2 +42,3 @@ "use strict"; | ||
// Add the child objectives to the current objectives | ||
const childObjectives = []; | ||
for (const objective of this._subject.getChildObjectives(objectiveFunction)) { | ||
@@ -48,4 +49,6 @@ if (!this._coveredObjectives.has(objective) && | ||
this._currentObjectives.add(objective); | ||
childObjectives.push(objective); | ||
} | ||
} | ||
return childObjectives; | ||
} | ||
@@ -52,0 +55,0 @@ } |
@@ -16,3 +16,3 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): void; | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -19,0 +19,0 @@ * @inheritDoc |
@@ -38,2 +38,3 @@ "use strict"; | ||
this._coveredObjectives.add(objectiveFunction); | ||
return []; | ||
} | ||
@@ -40,0 +41,0 @@ /** |
@@ -15,3 +15,3 @@ import { Encoding } from "../../Encoding"; | ||
*/ | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): void; | ||
protected _updateObjectives(objectiveFunction: ObjectiveFunction<T>): ObjectiveFunction<T>[]; | ||
/** | ||
@@ -18,0 +18,0 @@ * @inheritDoc |
@@ -38,2 +38,3 @@ "use strict"; | ||
this._coveredObjectives.add(objectiveFunction); | ||
return []; | ||
} | ||
@@ -40,0 +41,0 @@ /** |
{ | ||
"name": "@syntest/search", | ||
"version": "0.4.0-beta.36", | ||
"version": "0.4.0-beta.37", | ||
"description": "The common core of the SynTest Framework", | ||
@@ -65,3 +65,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "2bbe8297956eb73dbc30ee902a4dd1f8a6f2a34f" | ||
"gitHead": "a96ef7bf9d8c4b5b87ba69e9ed4d51b408f499a9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
309916
5355