-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
815 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { JsonObject } from "./json.js"; | ||
/** Provides details for branch coverage. */ | ||
export declare class BranchData { | ||
lineNumber: number; | ||
blockNumber: number; | ||
branchNumber: number; | ||
taken: number; | ||
/** | ||
* Creates a new branch data. | ||
* @param lineNumber The line number. | ||
* @param blockNumber The block number. | ||
* @param branchNumber The branch number. | ||
* @param taken A number indicating how often this branch was taken. | ||
*/ | ||
constructor(lineNumber: number, blockNumber: number, branchNumber: number, taken?: number); | ||
/** | ||
* Creates a new branch data from the specified JSON object. | ||
* @param map A JSON object representing a branch data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map: JsonObject): BranchData; | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON(): JsonObject; | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString(): string; | ||
} | ||
/** Provides the coverage data of branches. */ | ||
export declare class BranchCoverage { | ||
found: number; | ||
hit: number; | ||
data: BranchData[]; | ||
/** | ||
* Creates a new branch coverage. | ||
* @param found The number of branches found. | ||
* @param hit The number of branches hit. | ||
* @param data The coverage data. | ||
*/ | ||
constructor(found?: number, hit?: number, data?: BranchData[]); | ||
/** | ||
* Creates a new branch data from the specified JSON object. | ||
* @param map A JSON object representing a branch data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map: JsonObject): BranchCoverage; | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON(): JsonObject; | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Token } from "./token.js"; | ||
/** Provides details for branch coverage. */ | ||
export class BranchData { | ||
/** | ||
* Creates a new branch data. | ||
* @param lineNumber The line number. | ||
* @param blockNumber The block number. | ||
* @param branchNumber The branch number. | ||
* @param taken A number indicating how often this branch was taken. | ||
*/ | ||
constructor(lineNumber, blockNumber, branchNumber, taken = 0) { | ||
this.lineNumber = lineNumber; | ||
this.blockNumber = blockNumber; | ||
this.branchNumber = branchNumber; | ||
this.taken = taken; | ||
} | ||
/** | ||
* Creates a new branch data from the specified JSON object. | ||
* @param map A JSON object representing a branch data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map) { | ||
return new BranchData(typeof map.lineNumber == "number" && Number.isInteger(map.lineNumber) ? map.lineNumber : 0, typeof map.blockNumber == "number" && Number.isInteger(map.blockNumber) ? map.blockNumber : 0, typeof map.branchNumber == "number" && Number.isInteger(map.branchNumber) ? map.branchNumber : 0, typeof map.taken == "number" && Number.isInteger(map.taken) ? map.taken : 0); | ||
} | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON() { | ||
return { | ||
blockNumber: this.blockNumber, | ||
branchNumber: this.branchNumber, | ||
lineNumber: this.lineNumber, | ||
taken: this.taken | ||
}; | ||
} | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString() { | ||
const value = `${Token.branchData}:${this.lineNumber},${this.blockNumber},${this.branchNumber}`; | ||
return this.taken > 0 ? `${value},${this.taken}` : `${value},-`; | ||
} | ||
} | ||
/** Provides the coverage data of branches. */ | ||
export class BranchCoverage { | ||
/** | ||
* Creates a new branch coverage. | ||
* @param found The number of branches found. | ||
* @param hit The number of branches hit. | ||
* @param data The coverage data. | ||
*/ | ||
constructor(found = 0, hit = 0, data = []) { | ||
this.found = found; | ||
this.hit = hit; | ||
this.data = data; | ||
} | ||
/** | ||
* Creates a new branch data from the specified JSON object. | ||
* @param map A JSON object representing a branch data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map) { | ||
return new BranchCoverage(typeof map.found == "number" && Number.isInteger(map.found) ? map.found : 0, typeof map.hit == "number" && Number.isInteger(map.hit) ? map.hit : 0, Array.isArray(map.data) ? map.data.map(item => BranchData.fromJson(item)) : []); | ||
} | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON() { | ||
return { | ||
data: this.data.map(item => item.toJSON()), | ||
found: this.found, | ||
hit: this.hit | ||
}; | ||
} | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString() { | ||
const lines = this.data.map(item => item.toString()); | ||
lines.push(`${Token.branchesFound}:${this.found}`, `${Token.branchesHit}:${this.hit}`); | ||
return lines.join("\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { JsonObject } from "./json.js"; | ||
/** Provides details for function coverage. */ | ||
export declare class FunctionData { | ||
functionName: string; | ||
lineNumber: number; | ||
executionCount: number; | ||
/** | ||
* Creates a new function data. | ||
* @param functionName The function name. | ||
* @param lineNumber The line number of the function start. | ||
* @param executionCount The execution count. | ||
*/ | ||
constructor(functionName: string, lineNumber: number, executionCount?: number); | ||
/** | ||
* Creates a new function data from the specified JSON object. | ||
* @param map A JSON object representing a function data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map: JsonObject): FunctionData; | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON(): JsonObject; | ||
/** | ||
* Returns a string representation of this object. | ||
* @param asDefinition Whether to return the function definition (i.e. name and line number) instead of its data (i.e. name and execution count). | ||
* @return The string representation of this object. | ||
*/ | ||
toString(asDefinition?: boolean): string; | ||
} | ||
/** Provides the coverage data of functions. */ | ||
export declare class FunctionCoverage { | ||
found: number; | ||
hit: number; | ||
data: FunctionData[]; | ||
/** | ||
* Creates a new function coverage. | ||
* @param found The number of functions found. | ||
* @param hit The number of functions found. | ||
* @param data The coverage data. | ||
*/ | ||
constructor(found?: number, hit?: number, data?: FunctionData[]); | ||
/** | ||
* Creates a new function coverage from the specified JSON object. | ||
* @param map A JSON object representing a function coverage. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map: JsonObject): FunctionCoverage; | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON(): JsonObject; | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Token } from "./token.js"; | ||
/** Provides details for function coverage. */ | ||
export class FunctionData { | ||
/** | ||
* Creates a new function data. | ||
* @param functionName The function name. | ||
* @param lineNumber The line number of the function start. | ||
* @param executionCount The execution count. | ||
*/ | ||
constructor(functionName, lineNumber, executionCount = 0) { | ||
this.functionName = functionName; | ||
this.lineNumber = lineNumber; | ||
this.executionCount = executionCount; | ||
} | ||
/** | ||
* Creates a new function data from the specified JSON object. | ||
* @param map A JSON object representing a function data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map) { | ||
return new FunctionData(typeof map.functionName == "string" ? map.functionName : "", typeof map.lineNumber == "number" && Number.isInteger(map.lineNumber) ? map.lineNumber : 0, typeof map.executionCount == "number" && Number.isInteger(map.executionCount) ? map.executionCount : 0); | ||
} | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON() { | ||
return { | ||
executionCount: this.executionCount, | ||
functionName: this.functionName, | ||
lineNumber: this.lineNumber | ||
}; | ||
} | ||
/** | ||
* Returns a string representation of this object. | ||
* @param asDefinition Whether to return the function definition (i.e. name and line number) instead of its data (i.e. name and execution count). | ||
* @return The string representation of this object. | ||
*/ | ||
toString(asDefinition = false) { | ||
const token = asDefinition ? Token.functionName : Token.functionData; | ||
const count = asDefinition ? this.lineNumber : this.executionCount; | ||
return `${token}:${count},${this.functionName}`; | ||
} | ||
} | ||
/** Provides the coverage data of functions. */ | ||
export class FunctionCoverage { | ||
/** | ||
* Creates a new function coverage. | ||
* @param found The number of functions found. | ||
* @param hit The number of functions found. | ||
* @param data The coverage data. | ||
*/ | ||
constructor(found = 0, hit = 0, data = []) { | ||
this.found = found; | ||
this.hit = hit; | ||
this.data = data; | ||
} | ||
/** | ||
* Creates a new function coverage from the specified JSON object. | ||
* @param map A JSON object representing a function coverage. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map) { | ||
return new FunctionCoverage(typeof map.found == "number" && Number.isInteger(map.found) ? map.found : 0, typeof map.hit == "number" && Number.isInteger(map.hit) ? map.hit : 0, Array.isArray(map.data) ? map.data.map(item => FunctionData.fromJson(item)) : []); | ||
} | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON() { | ||
return { | ||
data: this.data.map(item => item.toJSON()), | ||
found: this.found, | ||
hit: this.hit | ||
}; | ||
} | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString() { | ||
const lines = this.data.map(item => item.toString(true)); | ||
lines.push(...this.data.map(item => item.toString(false))); | ||
lines.push(`${Token.functionsFound}:${this.found}`, `${Token.functionsHit}:${this.hit}`); | ||
return lines.join("\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from "./branch.js"; | ||
export * from "./function.js"; | ||
export * from "./json.js"; | ||
export * from "./line.js"; | ||
export * from "./record.js"; | ||
export * from "./report.js"; | ||
export * from "./token.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from "./branch.js"; | ||
export * from "./function.js"; | ||
export * from "./json.js"; | ||
export * from "./line.js"; | ||
export * from "./record.js"; | ||
export * from "./report.js"; | ||
export * from "./token.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** Defines the shape of a JSON value. */ | ||
export declare type Json = null | boolean | number | string | Json[] | { | ||
[property: string]: Json; | ||
}; | ||
/** Defines the shape of an object in JSON format. */ | ||
export declare type JsonObject = Record<string, Json>; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { JsonObject } from "./json.js"; | ||
/** Provides details for line coverage. */ | ||
export declare class LineData { | ||
lineNumber: number; | ||
executionCount: number; | ||
checksum: string; | ||
/** | ||
* Creates a new line data. | ||
* @param lineNumber The line number. | ||
* @param executionCount The execution count. | ||
* @param checksum The data checksum. | ||
*/ | ||
constructor(lineNumber: number, executionCount?: number, checksum?: string); | ||
/** | ||
* Creates a new line data from the specified JSON object. | ||
* @param map A JSON object representing a line data. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map: JsonObject): LineData; | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON(): JsonObject; | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString(): string; | ||
} | ||
/** Provides the coverage data of lines. */ | ||
export declare class LineCoverage { | ||
found: number; | ||
hit: number; | ||
data: LineData[]; | ||
/** | ||
* Creates a new line coverage. | ||
* @param found The number of lines found. | ||
* @param hit The number of lines found. | ||
* @param data The coverage data. | ||
*/ | ||
constructor(found?: number, hit?: number, data?: LineData[]); | ||
/** | ||
* Creates a new line coverage from the specified JSON object. | ||
* @param map A JSON object representing a line coverage. | ||
* @return The instance corresponding to the specified JSON object. | ||
*/ | ||
static fromJson(map: JsonObject): LineCoverage; | ||
/** | ||
* Converts this object to a map in JSON format. | ||
* @return The map in JSON format corresponding to this object. | ||
*/ | ||
toJSON(): JsonObject; | ||
/** | ||
* Returns a string representation of this object. | ||
* @return The string representation of this object. | ||
*/ | ||
toString(): string; | ||
} |
Oops, something went wrong.