Skip to content

Commit

Permalink
bugfix DependencyFinder.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Hendrey committed Jan 9, 2024
1 parent 770e866 commit 8835f9a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/DependencyFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ export default class DependencyFinder {
}

emitPaths() {

if(this.currentSteps.length === 0){
return;
}
const emitted: string[] = [];
const steps: StepRecord[] = this.currentSteps.flat(); //[[],["a","b"], ["c"]] -> ["a","b","c"]
const lastStepsArray = last(this.currentSteps);
Expand Down
35 changes: 35 additions & 0 deletions src/test/DependencyFinder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,41 @@ test("matrix4", () => {
]);
});

test("filter variable", () => {
const program = `$expected[$i]`;
const df = new DependencyFinder(program);
expect(df.findDependencies()).toEqual([
]);
});

test("big test expression", () => {
const program = `function($actual, $expected, $path) {(
$actual != $expected ? (
$type($actual) != $type($expected) ?
{'diff': {'path': $path, 'diff': 'type', 'expected': $type($expected), 'actual': $type($actual) }} :
$type($actual) = 'array' ?
(
$count($actual) != $count($expected) ?
{'diff': {'path': $path, 'diff': 'count', 'expected': $count($expected), 'actual': $count($actual)}}
: $map($actual, function($item, $i) {
compare($item, $expected[$i], $path & '[' & $i & ']' )
})~>$reduce($append);
) :
$type($actual) = 'object' ? compare($actual, $expected, $path) :
{'diff': {'path': $path, 'diff': 'value', 'expected': $expected, 'actual': $actual}}
)
)}`;
const df = new DependencyFinder(program);
expect(df.findDependencies()).toEqual([
[
"compare"
],
[
"compare"
]
]);
});




Expand Down

0 comments on commit 8835f9a

Please sign in to comment.