Skip to content

Commit

Permalink
Factorize creation of ExecutionTree
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Dec 21, 2018
1 parent a5fefe3 commit a46f079
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/check/runner/reporter/RunExecution.ts
Expand Up @@ -26,14 +26,15 @@ export class RunExecution<Ts> {
this.numSuccesses = 0;
}

private appendExecutionTree(status: ExecutionStatus, value: Ts) {
const currentTree: ExecutionTree<Ts> = { status, value, children: [] };
this.currentLevelExecutionTrees.push(currentTree);
return currentTree;
}

fail(value: Ts, id: number, message: string) {
if (this.verbosity >= VerbosityLevel.Verbose) {
const currentTree: ExecutionTree<Ts> = {
status: ExecutionStatus.Failure,
value,
children: []
};
this.currentLevelExecutionTrees.push(currentTree);
const currentTree = this.appendExecutionTree(ExecutionStatus.Failure, value);
this.currentLevelExecutionTrees = currentTree.children;
}
if (this.pathToFailure == null) this.pathToFailure = `${id}`;
Expand All @@ -43,23 +44,15 @@ export class RunExecution<Ts> {
}
skip(value: Ts) {
if (this.verbosity >= VerbosityLevel.VeryVerbose) {
this.currentLevelExecutionTrees.push({
status: ExecutionStatus.Skipped,
value,
children: []
});
this.appendExecutionTree(ExecutionStatus.Skipped, value);
}
if (this.pathToFailure == null) {
++this.numSkips;
}
}
success(value: Ts) {
if (this.verbosity >= VerbosityLevel.VeryVerbose) {
this.currentLevelExecutionTrees.push({
status: ExecutionStatus.Success,
value,
children: []
});
this.appendExecutionTree(ExecutionStatus.Success, value);
}
if (this.pathToFailure == null) {
++this.numSuccesses;
Expand Down

0 comments on commit a46f079

Please sign in to comment.