-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extracted branch trimming into own transformer
- Loading branch information
1 parent
61490e5
commit a45a6f6
Showing
3 changed files
with
107 additions
and
8 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
74 changes: 74 additions & 0 deletions
74
tests/system/cross_sync/test_cases/strip_async_conditional_branches.yaml
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,74 @@ | ||
tests: | ||
- description: "top level conditional" | ||
before: | | ||
if CrossSync.is_async: | ||
print("async") | ||
else: | ||
print("sync") | ||
transformers: [StripAsyncConditionalBranches] | ||
after: | | ||
print("sync") | ||
- description: "nested conditional" | ||
before: | | ||
if CrossSync.is_async: | ||
print("async") | ||
else: | ||
print("hello") | ||
if CrossSync.is_async: | ||
print("async") | ||
else: | ||
print("world") | ||
transformers: [StripAsyncConditionalBranches] | ||
after: | | ||
print("hello") | ||
print("world") | ||
- description: "conditional within class" | ||
before: | | ||
class MyClass: | ||
def my_method(self): | ||
if CrossSync.is_async: | ||
return "async result" | ||
else: | ||
return "sync result" | ||
transformers: [StripAsyncConditionalBranches] | ||
after: | | ||
class MyClass: | ||
def my_method(self): | ||
return "sync result" | ||
- description: "multiple branches" | ||
before: | | ||
if CrossSync.is_async: | ||
print("async branch 1") | ||
elif some_condition: | ||
print("other condition") | ||
elif CrossSync.is_async: | ||
print("async branch 2") | ||
else: | ||
print("sync branch") | ||
transformers: [StripAsyncConditionalBranches] | ||
after: | | ||
if some_condition: | ||
print("other condition") | ||
else: | ||
print("sync branch") | ||
- description: "negated conditionals" | ||
before: | | ||
if not CrossSync.is_async: | ||
print("sync code") | ||
else: | ||
print("async code") | ||
transformers: [StripAsyncConditionalBranches] | ||
after: | | ||
print("sync code") | ||
- description: "is check" | ||
before: | | ||
if CrossSync.is_async is True: | ||
print("async code") | ||
else: | ||
print("sync code") | ||
transformers: [StripAsyncConditionalBranches] | ||
after: | | ||
print("sync code") |
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