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 all 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/graph/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function diffVertices(ctx: DataflowDiffContext): void {
})
}
}
diffControlDependencies(lInfo.controlDependencies, rInfo.controlDependencies, { ...ctx, position: `Vertex ${id} differs in controlDependency. ` })
diffControlDependencies(lInfo.controlDependencies, rInfo.controlDependencies, { ...ctx, position: `Vertex ${id} differs in controlDependencies. ` })

diffEnvironmentInformation(lInfo.environment, rInfo.environment, { ...ctx, position: `${ctx.position}Vertex ${id} differs in environment. ` })

Expand Down
2 changes: 1 addition & 1 deletion src/r-bridge/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ export const flowrCapabilities = {
name: 'Sequencing',
id: 'built-in-sequencing',
supported: 'not',
description: '_Handle `:`, `seq`, ... as they are used often._'
description: '_Handle `:`, `seq`, ... by gathering value information using abstract interpretation._'
},
{
name: 'Internal and Primitive Functions',
Expand Down
2 changes: 1 addition & 1 deletion src/r-bridge/lang-4.x/ast/model/operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const OperatorDatabase: Record<StringUsedInRCode, OperatorInformationValu
'=': { name: 'equal assignment', stringUsedInRAst: RawRType.EqualAssign, stringUsedInternally: '=', writtenAs: 'infix', arity: OperatorArity.Binary, usedAs: 'assignment', capabilities: ['binary-operator', 'infix-calls', 'assignment-functions', 'local-equal-assignment', 'function-calls'] },
/* others */
/* maybe introduce custom in-r-ast flavor for these? we consider it arithmetic, as it works on numbers => if we change this we have to create custom tests! (with arithmetic, there is the automatic test set) */
':': { name: 'sequence operator', stringUsedInRAst: RawRType.Colon, stringUsedInternally: ':', writtenAs: 'infix', arity: OperatorArity.Binary, usedAs: 'operation', capabilities: ['binary-operator', 'infix-calls', 'function-calls', 'built-in-sequencing'] },
':': { name: 'sequence operator', stringUsedInRAst: RawRType.Colon, stringUsedInternally: ':', writtenAs: 'infix', arity: OperatorArity.Binary, usedAs: 'operation', capabilities: ['binary-operator', 'infix-calls', 'function-calls'] },
'?': { name: 'question', stringUsedInRAst: RawRType.Question, stringUsedInternally: '?', writtenAs: 'prefix', arity: OperatorArity.Unary, usedAs: 'operation', capabilities: ['unary-operator', 'built-in-help'] }
}
/* eslint-enable */
Expand Down
10 changes: 5 additions & 5 deletions test/functionality/_helper/dataflow/dataflow-builder-printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { assertUnreachable, isNotUndefined } from '../../../../src/util/assert'
import { DefaultMap } from '../../../../src/util/defaultmap'
import { EnvironmentBuilderPrinter } from './environment-builder-printer'
import { wrap, wrapControlDependency, wrapReference } from './printer'
import { wrap, wrapControlDependencies, wrapReference } from './printer'
import { EdgeType, splitEdgeTypes } from '../../../../src/dataflow/graph/edge'
import type { DataflowGraph, FunctionArgument } from '../../../../src/dataflow/graph/graph'
import { isPositionalArgument } from '../../../../src/dataflow/graph/graph'
Expand Down Expand Up @@ -128,13 +128,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 @@ -154,7 +154,7 @@ class DataflowBuilderPrinter {
}
}

private controlDependencyForArgument(id: NodeId): ControlDependency[] | undefined {
private controlDependenciesForArgument(id: NodeId): ControlDependency[] | 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 @@ -248,7 +248,7 @@ class DataflowBuilderPrinter {

private getControlDependencySuffix(arg: ControlDependency[] | undefined, prefix: string = '{ ', suffix: string = ' }'): string | undefined {
if(arg !== undefined) {
return `${prefix}controlDependency: ${wrapControlDependency(arg)}${suffix}`
return `${prefix}controlDependencies: ${wrapControlDependencies(arg)}${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 @@ -41,7 +41,7 @@ export class DataflowGraphBuilder extends DataflowGraph {
*/
public defineFunction(id: NodeId,
exitPoints: readonly NodeId[], subflow: DataflowFunctionFlowInformation,
info?: { environment?: REnvironmentInformation, controlDependency?: ControlDependency[] },
info?: { environment?: REnvironmentInformation, controlDependencies?: ControlDependency[] },
asRoot: boolean = true) {
return this.addVertex({
tag: VertexType.FunctionDefinition,
Expand All @@ -55,7 +55,7 @@ export class DataflowGraphBuilder extends DataflowGraph {
unknownReferences: subflow.unknownReferences.map(o => ({ ...o, nodeId: normalizeIdToNumberIfPossible(o.nodeId), controlDependencies: o.controlDependencies?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })) }))
} as DataflowFunctionFlowInformation,
exitPoints: exitPoints.map(normalizeIdToNumberIfPossible),
controlDependencies: info?.controlDependency?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
controlDependencies: info?.controlDependencies?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
environment: info?.environment
}, asRoot)
}
Expand All @@ -72,21 +72,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?: ControlDependency[]
returns?: readonly NodeId[],
reads?: readonly NodeId[],
onlyBuiltIn?: boolean,
environment?: REnvironmentInformation,
controlDependencies?: ControlDependency[]
},
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(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
controlDependencies: info?.controlDependencies?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
onlyBuiltin: info?.onlyBuiltIn ?? onlyBuiltInAuto ?? false
}, asRoot)
this.addArgumentLinks(id, args)
Expand Down Expand Up @@ -132,12 +132,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?: ControlDependency[], definedBy?: NodeId[]}, asRoot: boolean = true) {
info?: { controlDependencies?: ControlDependency[], definedBy?: NodeId[]}, asRoot: boolean = true) {
this.addVertex({
tag: VertexType.VariableDefinition,
id: normalizeIdToNumberIfPossible(id),
name,
controlDependencies: info?.controlDependency?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
controlDependencies: info?.controlDependencies?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
}, asRoot)
if(info?.definedBy) {
for(const def of info.definedBy) {
Expand Down Expand Up @@ -178,11 +178,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?: ControlDependency[] }, asRoot: boolean = true) {
public constant(id: NodeId, options?: { controlDependencies?: ControlDependency[] }, asRoot: boolean = true) {
return this.addVertex({
tag: VertexType.Value,
id: normalizeIdToNumberIfPossible(id),
controlDependencies: options?.controlDependency?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
controlDependencies: options?.controlDependencies?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })),
environment: undefined
}, asRoot)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertUnreachable, isNotUndefined } from '../../../../src/util/assert'
import { wrap, wrapControlDependency } from './printer'
import { wrap, wrapControlDependencies } from './printer'
import type { IEnvironment, REnvironmentInformation } from '../../../../src/dataflow/environments/environment'
import { BuiltInEnvironment } from '../../../../src/dataflow/environments/environment'
import type { IdentifierDefinition } from '../../../../src/dataflow/environments/identifier'
Expand Down Expand Up @@ -77,7 +77,7 @@ export class EnvironmentBuilderPrinter {
}

private getControlDependencyArgument(def: IdentifierDefinition) {
return def.controlDependencies ? wrapControlDependency(def.controlDependencies) : undefined
return def.controlDependencies ? wrapControlDependencies(def.controlDependencies) : undefined
}

private push() {
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 @@ -18,8 +18,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?: ControlDependency[] }): FunctionArgument {
return { nodeId: normalizeIdToNumberIfPossible(nodeId), name: options?.name, controlDependencies: options?.controlDependency?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })) }
export function argumentInCall(nodeId: NodeId, options?: { name?: string, controlDependencies?: ControlDependency[] }): FunctionArgument {
return { nodeId: normalizeIdToNumberIfPossible(nodeId), name: options?.name, controlDependencies: options?.controlDependencies?.map(c => ({ ...c, id: normalizeIdToNumberIfPossible(c.id) })) }
}
/**
* 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 @@ -21,15 +21,15 @@ export function wrap(id: string | NodeId | undefined): string {
}
}

export function wrapControlDependency(controlDependency: ControlDependency[] | undefined): string {
if(controlDependency === undefined) {
export function wrapControlDependencies(controlDependencies: ControlDependency[] | undefined): string {
if(controlDependencies === undefined) {
return 'undefined'
} else {
return `[${controlDependency.map(c =>
return `[${controlDependencies.map(c =>
`{ id: ${wrap(c.id)}, when: ${c.when} }`
).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)} }`
}
2 changes: 2 additions & 0 deletions test/functionality/_helper/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export function assertSliced(name: string | TestLabel, shell: RShell, input: str
const fullname = decorateLabelContext(name, ['slice'])

const t = it(`${JSON.stringify(criteria)} ${fullname}`, async function() {
await ensureConfig(shell, this, userConfig)

const result = await new PipelineExecutor(DEFAULT_RECONSTRUCT_PIPELINE,{
getId,
request: requestFromInput(input),
Expand Down
Loading
Loading