-
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: optionally generate code without runner integration (#836)
Closes #831 - allow not generating runner function calls (memoized function call, placeholder saving) - added test for eject functionality + tests that begin with "eject" are automatically tested without runner support --------- Co-authored-by: megalinter-bot <[email protected]>
- Loading branch information
1 parent
21298d0
commit 0ed9d6e
Showing
14 changed files
with
219 additions
and
31 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
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 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
24 changes: 24 additions & 0 deletions
24
packages/safe-ds-lang/tests/resources/generation/eject/input.sdstest
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,24 @@ | ||
package tests.generator.eject | ||
|
||
@Impure([ImpurityReason.Other]) fun f(param: Any?) | ||
|
||
@Pure fun g() -> result: Boolean | ||
|
||
@Pure fun i() -> result: Int? | ||
|
||
@Pure fun factory() -> instance: C? | ||
|
||
class C() { | ||
attr a: Int | ||
@PythonName("c") attr b: Int | ||
} | ||
|
||
pipeline test { | ||
f(g() or g()); | ||
f(g() and g()); | ||
|
||
f(factory()?.a); | ||
f(factory()?.b); | ||
|
||
f(i() ?: i()); | ||
} |
30 changes: 30 additions & 0 deletions
30
...s/safe-ds-lang/tests/resources/generation/eject/output/tests/generator/eject/gen_input.py
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,30 @@ | ||
# Imports ---------------------------------------------------------------------- | ||
|
||
from typing import Any, TypeVar | ||
|
||
# Utils ------------------------------------------------------------------------ | ||
|
||
def __gen_eager_or(left_operand: bool, right_operand: bool) -> bool: | ||
return left_operand or right_operand | ||
|
||
def __gen_eager_and(left_operand: bool, right_operand: bool) -> bool: | ||
return left_operand and right_operand | ||
|
||
__gen_S = TypeVar("__gen_S") | ||
|
||
def __gen_safe_access(receiver: Any, member_name: str) -> __gen_S | None: | ||
return getattr(receiver, member_name) if receiver is not None else None | ||
|
||
__gen_T = TypeVar("__gen_T") | ||
|
||
def __gen_eager_elvis(left_operand: __gen_T, right_operand: __gen_T) -> __gen_T: | ||
return left_operand if left_operand is not None else right_operand | ||
|
||
# Pipelines -------------------------------------------------------------------- | ||
|
||
def test(): | ||
f(__gen_eager_or(g(), g())) | ||
f(__gen_eager_and(g(), g())) | ||
f(__gen_safe_access(factory(), 'a')) | ||
f(__gen_safe_access(factory(), 'c')) | ||
f(__gen_eager_elvis(i(), i())) |
Oops, something went wrong.