@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
58 lines (57 loc) • 2.58 kB
TypeScript
/**
* Provides utility types and functions to provide difference information if two structures
* are not equal. Maybe. Sometime, in the far future this will be as capable as the waldo package :dream:
* @module
*/
import type { MergeableRecord } from './objects';
/**
* Unifies the shape of all difference reports.
* They should have an array of comments on the potential differences/equality of
* the structures and a function to check if they are really equal.
*/
export interface DifferenceReport {
/**
* A human-readable description of differences during the comparison
* In combination with {@link isEqual} this can be used to provide detailed
* explanation on equal structures as well (e.g., if structures _could_ be equal).
*/
comments(): readonly string[] | undefined;
/**
* @returns true iff the compared structures are equal (i.e., the diff is empty)
*/
isEqual(): boolean;
}
export interface WriteableDifferenceReport extends DifferenceReport {
addComment(comment: string): void;
}
/**
* Identifies the information required by the core difference functions.
* The `leftname` and `rightname` fields are only used to provide more useful
* information in the difference report.
*/
export interface GenericDifferenceInformation<Report extends WriteableDifferenceReport> extends MergeableRecord {
/** A human-readable name for the left structure in `left == right`. */
readonly leftname: string;
/** A human-readable name for the right structure in `left == right`. */
readonly rightname: string;
/** The report on the difference of the two structures. */
readonly report: Report;
/** A human-readable indication of where we are (the prefix of the information if the structures differ) */
readonly position: string;
readonly config: GenericDiffConfiguration;
}
export interface GenericDiffConfiguration {
/**
* The left/first graph may contain more vertices and or edges than the right/second graph.
* However, those which are the same (based on their ids) have to be equal
*/
readonly rightIsSubgraph?: boolean;
/**
* Similar to {@link rightIsSubgraph}, but for the left/first graph.
*/
readonly leftIsSubgraph?: boolean;
}
/**
* Computes the difference of two sets and adds human-readable information to the current report
*/
export declare function setDifference<T, Report extends WriteableDifferenceReport = WriteableDifferenceReport>(left: ReadonlySet<T>, right: ReadonlySet<T>, info: GenericDifferenceInformation<Report>): void;