-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60908a1
commit 05b95f8
Showing
2 changed files
with
68 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,46 @@ | ||
from rewrite.test import rewrite_run, python | ||
|
||
|
||
def test_basic_comprehension(): | ||
def test_basic_list_comprehension(): | ||
# language=python | ||
rewrite_run(python("a = [ e+1 for e in [1, 2, ]]")) | ||
|
||
|
||
def test_comprehension_with_if(): | ||
def test_list_comprehension_with_if(): | ||
# language=python | ||
rewrite_run(python("a = [ e+1 for e in [1, 2, ] if e > 1]")) | ||
|
||
|
||
def test_comprehension_with_multiple_ifs(): | ||
def test_list_comprehension_with_multiple_ifs(): | ||
# language=python | ||
rewrite_run(python("a = [ e+1 for e in [1, 2, ] if e > 1 if e < 10]")) | ||
|
||
|
||
def test_basic_set_comprehension(): | ||
# language=python | ||
rewrite_run(python("a = { e for e in range(10)}")) | ||
|
||
|
||
def test_set_comprehension_with_if(): | ||
# language=python | ||
rewrite_run(python("a = { e for e in range(10) if e > 1}")) | ||
|
||
|
||
def test_set_comprehension_with_multiple_ifs(): | ||
# language=python | ||
rewrite_run(python("a = { e for e in range(10) if e > 1 if e < 10}")) | ||
|
||
|
||
def test_basic_dict_comprehension(): | ||
# language=python | ||
rewrite_run(python("a = {n: n * 2 for n in range(10)}")) | ||
|
||
|
||
def test_dict_comprehension_with_if(): | ||
# language=python | ||
rewrite_run(python("a = {e:e for e in range(10) if e > 1}")) | ||
|
||
|
||
def test_dict_comprehension_with_multiple_ifs(): | ||
# language=python | ||
rewrite_run(python("a = {e:None for e in range(10) if e > 1 if e < 10}")) |