-
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.
feat: compute purity/side effects for expressions (#785)
### Summary of Changes The purity computer can now compute the purity for arbitrary expressions (instead of just calls). This is needed, for example, for #15.
- Loading branch information
1 parent
b09bb3a
commit 9ed1c08
Showing
11 changed files
with
348 additions
and
108 deletions.
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,27 @@ | ||
# Call Graph Testing | ||
|
||
Call graph tests are data-driven instead of being specified explicitly. This document explains how to add a new call | ||
graph test. | ||
|
||
## Adding a call graph test | ||
|
||
1. Create a new file with the extension `.sdstest` in the `tests/resources/call graph` directory or any subdirectory. | ||
Give the file a descriptive name, since the file name becomes part of the test name. | ||
|
||
!!! tip "Skipping a test" | ||
|
||
If you want to skip a test, add the prefix `skip-` to the file name. | ||
|
||
2. Add the Safe-DS code that you want to test to the file. | ||
3. Surround calls or callables for which you want to compute a call graph with test markers, e.g. `»f()«`. Add a | ||
comment in the preceding line with the following format: | ||
```ts | ||
// $TEST$ ["f", "$blockLambda", "$expressionLambda", "undefined"] | ||
``` | ||
The comment must contain an array with the names of the callables that are expected to be called. The order must | ||
match the actual call order. The names must be: | ||
* The quoted name of a named callable, e.g. `"f"`. | ||
* The string `"$blockLambda"` for a block lambda. | ||
* The string `"$expressionLambda"` for an expression lambda. | ||
* The string `"undefined"` for an undefined callable. | ||
4. Run the tests. The test runner will automatically pick up the new test. |
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
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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { AstNode, hasContainerOfType } from 'langium'; | ||
|
||
/** | ||
* Returns whether the inner node is contained in the outer node. If the nodes are equal, this function returns `true`. | ||
* Returns whether the inner node is contained in the outer node or equal to it. | ||
*/ | ||
export const isContainedIn = (inner: AstNode | undefined, outer: AstNode | undefined): boolean => { | ||
export const isContainedInOrEqual = (inner: AstNode | undefined, outer: AstNode | undefined): boolean => { | ||
return hasContainerOfType(inner, (it) => it === outer); | ||
}; |
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
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
Oops, something went wrong.