Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional tests #800

Merged
merged 29 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fb0fc02
test: start on expanding get/assign slicing tests
Ellpeck May 18, 2024
e7f9849
test: additional get/assign tests
Ellpeck May 18, 2024
31727a8
test: control flow slicing tests
Ellpeck May 18, 2024
697783d
test: fixed up existing tests
Ellpeck May 20, 2024
bdecd12
Merge branch 'main' into additional-tests
Ellpeck May 20, 2024
c2a9cbb
test: finished additional slicing tests
Ellpeck May 20, 2024
fcb443e
test(wip): start on dataflow tests
Ellpeck May 20, 2024
cf29fe0
test(wip): additional dataflow tests
Ellpeck May 20, 2024
52ef225
Merge branch 'main' into additional-tests
Ellpeck May 22, 2024
882c5e0
test: additional dataflow tests
Ellpeck May 22, 2024
d953e5b
refactor: unify controlDependencies naming
Ellpeck May 22, 2024
fb7d76a
test: branch coverage df tests for repeat, for and while
Ellpeck May 22, 2024
eefafb0
test: finished up initial batch of dataflow tests
Ellpeck May 22, 2024
ba517bb
Merge branch 'main' into additional-tests
Ellpeck May 23, 2024
0a14c38
test: added dead code dataflow tests
Ellpeck May 23, 2024
286fba9
test: added dead code slicing tests
Ellpeck May 23, 2024
de3cb5a
Merge branch 'main' into additional-tests
Ellpeck May 24, 2024
ec0537d
refactor(test): updated tests to new features
Ellpeck May 24, 2024
d51e26d
test: add additional labels to some tests
Ellpeck May 24, 2024
391dec6
test: fix assignment of unsupported claims
Ellpeck May 24, 2024
6e927f0
test: additional dataflow tests in various categories
Ellpeck May 24, 2024
7ee954f
feat-fix: fixed errors when running new tests on 4.0.0
Ellpeck May 24, 2024
e4b8731
test: added slice versions of new dataflow tests
Ellpeck May 24, 2024
56b803b
feat-fix: fixed source provider settings in tests
Ellpeck May 24, 2024
d13605d
doc: annotate incorrect tests with their corresponding issues
Ellpeck May 24, 2024
3028a13
feat-fix: fixed slice tests not ensuring the user config matches
Ellpeck May 24, 2024
ddd8049
Merge branch 'main' into additional-tests
Ellpeck May 27, 2024
80f2031
test: updated tests to new fixes
Ellpeck May 27, 2024
0390258
Merge branch 'main' into additional-tests
EagleoutIce May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dataflow/environments/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
info.report.addComment(`${info.position}Different ids for ${key}. ${info.leftname}: ${aVal.nodeId} vs. ${info.rightname}: ${bVal.nodeId}`)
}
if(!arrayEqual(aVal.controlDependencies, bVal.controlDependencies)) {
info.report.addComment(`${info.position}Different controlDependency for ${key} (${aVal.nodeId}). ${info.leftname}: ${JSON.stringify(aVal.controlDependencies)} vs. ${info.rightname}: ${JSON.stringify(bVal.controlDependencies)}`)
info.report.addComment(`${info.position}Different controlDependencies for ${key} (${aVal.nodeId}). ${info.leftname}: ${JSON.stringify(aVal.controlDependencies)} vs. ${info.rightname}: ${JSON.stringify(bVal.controlDependencies)}`)

Check warning on line 48 in src/dataflow/environments/diff.ts

View check run for this annotation

Codecov / codecov/patch

src/dataflow/environments/diff.ts#L48

Added line #L48 was not covered by tests
}
if(aVal.definedAt !== bVal.definedAt) {
info.report.addComment(`${info.position}Different definition ids (definedAt) for ${key} (${aVal.nodeId}). ${info.leftname}: ${aVal.definedAt} vs. ${info.rightname}: ${bVal.definedAt}`)
Expand Down
2 changes: 1 addition & 1 deletion src/dataflow/graph/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export function diffVertices(ctx: DataflowDiffContext): void {
}
if(!arrayEqual(lInfo.controlDependencies, rInfo.controlDependencies)) {
ctx.report.addComment(
`Vertex ${id} differs in controlDependency. ${ctx.leftname}: ${JSON.stringify(lInfo.controlDependencies)} vs ${ctx.rightname}: ${JSON.stringify(rInfo.controlDependencies)}`,
`Vertex ${id} differs in controlDependencies. ${ctx.leftname}: ${JSON.stringify(lInfo.controlDependencies)} vs ${ctx.rightname}: ${JSON.stringify(rInfo.controlDependencies)}`,
{ tag: 'vertex', id }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ class DataflowBuilderPrinter {
if(arg === undefined || arg === EmptyArgument) {
return 'EmptyArgument'
} else if(isPositionalArgument(arg)) {
const suffix = this.getControlDependencySuffix(this.controlDependencyForArgument(arg.nodeId), ', { ') ?? ''
const suffix = this.getControlDependencySuffix(this.controlDependenciesForArgument(arg.nodeId), ', { ') ?? ''
this.handleArgumentArgLinkage(fn, arg.nodeId)
return `argumentInCall('${arg.nodeId}'${suffix})`
} else {
this.coveredVertices.add(arg.nodeId)
this.handleArgumentArgLinkage(fn, arg.nodeId)
const suffix = this.getControlDependencySuffix(this.controlDependencyForArgument(arg.nodeId), ', ', '') ?? ''
const suffix = this.getControlDependencySuffix(this.controlDependenciesForArgument(arg.nodeId), ', ', '') ?? ''
return `argumentInCall('${arg.nodeId}', { name: '${arg.name}'${suffix} } )`
}
}
Expand All @@ -153,7 +153,7 @@ class DataflowBuilderPrinter {
}
}

private controlDependencyForArgument(id: NodeId): NodeId[] | undefined {
private controlDependenciesForArgument(id: NodeId): NodeId[] | undefined {
// we ignore the control dependency of the argument in the call as it is usually separate, and the auto creation
// will respect the corresponding node!
return this.graph.getVertex(id, true)?.controlDependencies
Expand Down Expand Up @@ -247,7 +247,7 @@ class DataflowBuilderPrinter {

private getControlDependencySuffix(arg: NodeId[] | undefined, prefix: string = '{ ', suffix: string = ' }'): string | undefined {
if(arg !== undefined) {
return `${prefix}controlDependency: [${arg.map(id => wrap(id)).join(', ')}]${suffix}`
return `${prefix}controlDependencies: [${arg.map(id => wrap(id)).join(', ')}]${suffix}`
}
return undefined
}
Expand Down
26 changes: 13 additions & 13 deletions test/functionality/_helper/dataflow/dataflowgraph-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class DataflowGraphBuilder extends DataflowGraph {
*/
public defineFunction(id: NodeId,
exitPoints: readonly NodeId[], subflow: DataflowFunctionFlowInformation,
info?: { environment?: REnvironmentInformation, controlDependency?: NodeId[] },
info?: { environment?: REnvironmentInformation, controlDependencies?: NodeId[] },
asRoot: boolean = true) {
return this.addVertex({
tag: VertexType.FunctionDefinition,
Expand All @@ -54,7 +54,7 @@ export class DataflowGraphBuilder extends DataflowGraph {
unknownReferences: subflow.unknownReferences.map(o => ({ ...o, nodeId: normalizeIdToNumberIfPossible(o.nodeId), controlDependencies: o.controlDependencies?.map(normalizeIdToNumberIfPossible) }))
} as DataflowFunctionFlowInformation,
exitPoints: exitPoints.map(normalizeIdToNumberIfPossible),
controlDependencies: info?.controlDependency?.map(normalizeIdToNumberIfPossible),
controlDependencies: info?.controlDependencies?.map(normalizeIdToNumberIfPossible),
environment: info?.environment
}, asRoot)
}
Expand All @@ -71,21 +71,21 @@ export class DataflowGraphBuilder extends DataflowGraph {
*/
public call(id: NodeId, name: string, args: FunctionArgument[],
info?: {
returns?: readonly NodeId[],
reads?: readonly NodeId[],
onlyBuiltIn?: boolean,
environment?: REnvironmentInformation,
controlDependency?: NodeId[]
returns?: readonly NodeId[],
reads?: readonly NodeId[],
onlyBuiltIn?: boolean,
environment?: REnvironmentInformation,
controlDependencies?: NodeId[]
},
asRoot: boolean = true) {
const onlyBuiltInAuto = info?.reads?.length === 1 && info?.reads[0] === BuiltIn
this.addVertex({
tag: VertexType.FunctionCall,
id: normalizeIdToNumberIfPossible(id),
name,
args: args.map(a => a === EmptyArgument ? EmptyArgument : { ...a, nodeId: normalizeIdToNumberIfPossible(a.nodeId), controlDependency: undefined }),
args: args.map(a => a === EmptyArgument ? EmptyArgument : { ...a, nodeId: normalizeIdToNumberIfPossible(a.nodeId), controlDependencies: undefined }),
environment: info?.environment ?? initializeCleanEnvironments(),
controlDependencies: info?.controlDependency?.map(normalizeIdToNumberIfPossible),
controlDependencies: info?.controlDependencies?.map(normalizeIdToNumberIfPossible),
onlyBuiltin: info?.onlyBuiltIn ?? onlyBuiltInAuto ?? false
}, asRoot)
this.addArgumentLinks(id, args)
Expand Down Expand Up @@ -131,12 +131,12 @@ export class DataflowGraphBuilder extends DataflowGraph {
* (i.e., be a valid entry point), or is it nested (e.g., as part of a function definition)
*/
public defineVariable(id: NodeId, name: string,
info?: { controlDependency?: NodeId[], definedBy?: NodeId[]}, asRoot: boolean = true) {
info?: { controlDependencies?: NodeId[], definedBy?: NodeId[]}, asRoot: boolean = true) {
this.addVertex({
tag: VertexType.VariableDefinition,
id: normalizeIdToNumberIfPossible(id),
name,
controlDependencies: info?.controlDependency?.map(normalizeIdToNumberIfPossible),
controlDependencies: info?.controlDependencies?.map(normalizeIdToNumberIfPossible),
}, asRoot)
if(info?.definedBy) {
for(const def of info.definedBy) {
Expand Down Expand Up @@ -177,11 +177,11 @@ export class DataflowGraphBuilder extends DataflowGraph {
* @param asRoot - should the vertex be part of the root vertex set of the graph
* (i.e., be a valid entry point), or is it nested (e.g., as part of a function definition)
*/
public constant(id: NodeId, options?: { controlDependency?: NodeId[] }, asRoot: boolean = true) {
public constant(id: NodeId, options?: { controlDependencies?: NodeId[] }, asRoot: boolean = true) {
return this.addVertex({
tag: VertexType.Value,
id: normalizeIdToNumberIfPossible(id),
controlDependencies: options?.controlDependency?.map(normalizeIdToNumberIfPossible),
controlDependencies: options?.controlDependencies?.map(normalizeIdToNumberIfPossible),
environment: undefined
}, asRoot)
}
Expand Down
4 changes: 2 additions & 2 deletions test/functionality/_helper/dataflow/environment-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function variable(name: string, definedAt: NodeId): IdentifierDefinition
* @param nodeId - AST Node ID
* @param options - optional allows to give further options
*/
export function argumentInCall(nodeId: NodeId, options?: { name?: string, controlDependency?: NodeId[] }): FunctionArgument {
return { nodeId: normalizeIdToNumberIfPossible(nodeId), name: options?.name, controlDependencies: options?.controlDependency?.map(normalizeIdToNumberIfPossible) }
export function argumentInCall(nodeId: NodeId, options?: { name?: string, controlDependencies?: NodeId[] }): FunctionArgument {
return { nodeId: normalizeIdToNumberIfPossible(nodeId), name: options?.name, controlDependencies: options?.controlDependencies?.map(normalizeIdToNumberIfPossible) }
}
/**
* The constant global environment with all pre-defined functions.
Expand Down
8 changes: 4 additions & 4 deletions test/functionality/_helper/dataflow/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export function wrap(id: string | NodeId | undefined): string {
}
}

function wrapControlDependency(controlDependency: NodeId[] | undefined): string {
if(controlDependency === undefined) {
function wrapControlDependencies(controlDependencies: NodeId[] | undefined): string {
if(controlDependencies === undefined) {
return 'undefined'
} else {
return `[${controlDependency.map(wrap).join(', ')}]`
return `[${controlDependencies.map(wrap).join(', ')}]`
}
}
export function wrapReference(ref: IdentifierReference): string {
return `{ nodeId: ${wrap(ref.nodeId)}, name: ${wrap(ref.name)}, controlDependencies: ${wrapControlDependency(ref.controlDependencies)} }`
return `{ nodeId: ${wrap(ref.nodeId)}, name: ${wrap(ref.name)}, controlDependencies: ${wrapControlDependencies(ref.controlDependencies)} }`
}
Loading
Loading