Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
74f56878
Unverified
Kaydet (Commit)
74f56878
authored
Mar 13, 2018
tarafından
Łukasz Langa
Kaydeden (comit)
GitHub
Mar 13, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
lib2to3: Add more tests (#6101)
üst
b8e9d6c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
test_parser.py
Lib/lib2to3/tests/test_parser.py
+108
-0
No files found.
Lib/lib2to3/tests/test_parser.py
Dosyayı görüntüle @
74f56878
...
...
@@ -274,6 +274,78 @@ class TestUnpackingGeneralizations(GrammarTest):
def
test_argument_unpacking_3
(
self
):
self
.
validate
(
"""f(2, *a, *b, **b, **c, **d)"""
)
def
test_trailing_commas_1
(
self
):
self
.
validate
(
"def f(a, b): call(a, b)"
)
self
.
validate
(
"def f(a, b,): call(a, b,)"
)
def
test_trailing_commas_2
(
self
):
self
.
validate
(
"def f(a, *b): call(a, *b)"
)
self
.
validate
(
"def f(a, *b,): call(a, *b,)"
)
def
test_trailing_commas_3
(
self
):
self
.
validate
(
"def f(a, b=1): call(a, b=1)"
)
self
.
validate
(
"def f(a, b=1,): call(a, b=1,)"
)
def
test_trailing_commas_4
(
self
):
self
.
validate
(
"def f(a, **b): call(a, **b)"
)
self
.
validate
(
"def f(a, **b,): call(a, **b,)"
)
def
test_trailing_commas_5
(
self
):
self
.
validate
(
"def f(*a, b=1): call(*a, b=1)"
)
self
.
validate
(
"def f(*a, b=1,): call(*a, b=1,)"
)
def
test_trailing_commas_6
(
self
):
self
.
validate
(
"def f(*a, **b): call(*a, **b)"
)
self
.
validate
(
"def f(*a, **b,): call(*a, **b,)"
)
def
test_trailing_commas_7
(
self
):
self
.
validate
(
"def f(*, b=1): call(*b)"
)
self
.
validate
(
"def f(*, b=1,): call(*b,)"
)
def
test_trailing_commas_8
(
self
):
self
.
validate
(
"def f(a=1, b=2): call(a=1, b=2)"
)
self
.
validate
(
"def f(a=1, b=2,): call(a=1, b=2,)"
)
def
test_trailing_commas_9
(
self
):
self
.
validate
(
"def f(a=1, **b): call(a=1, **b)"
)
self
.
validate
(
"def f(a=1, **b,): call(a=1, **b,)"
)
def
test_trailing_commas_lambda_1
(
self
):
self
.
validate
(
"f = lambda a, b: call(a, b)"
)
self
.
validate
(
"f = lambda a, b,: call(a, b,)"
)
def
test_trailing_commas_lambda_2
(
self
):
self
.
validate
(
"f = lambda a, *b: call(a, *b)"
)
self
.
validate
(
"f = lambda a, *b,: call(a, *b,)"
)
def
test_trailing_commas_lambda_3
(
self
):
self
.
validate
(
"f = lambda a, b=1: call(a, b=1)"
)
self
.
validate
(
"f = lambda a, b=1,: call(a, b=1,)"
)
def
test_trailing_commas_lambda_4
(
self
):
self
.
validate
(
"f = lambda a, **b: call(a, **b)"
)
self
.
validate
(
"f = lambda a, **b,: call(a, **b,)"
)
def
test_trailing_commas_lambda_5
(
self
):
self
.
validate
(
"f = lambda *a, b=1: call(*a, b=1)"
)
self
.
validate
(
"f = lambda *a, b=1,: call(*a, b=1,)"
)
def
test_trailing_commas_lambda_6
(
self
):
self
.
validate
(
"f = lambda *a, **b: call(*a, **b)"
)
self
.
validate
(
"f = lambda *a, **b,: call(*a, **b,)"
)
def
test_trailing_commas_lambda_7
(
self
):
self
.
validate
(
"f = lambda *, b=1: call(*b)"
)
self
.
validate
(
"f = lambda *, b=1,: call(*b,)"
)
def
test_trailing_commas_lambda_8
(
self
):
self
.
validate
(
"f = lambda a=1, b=2: call(a=1, b=2)"
)
self
.
validate
(
"f = lambda a=1, b=2,: call(a=1, b=2,)"
)
def
test_trailing_commas_lambda_9
(
self
):
self
.
validate
(
"f = lambda a=1, **b: call(a=1, **b)"
)
self
.
validate
(
"f = lambda a=1, **b,: call(a=1, **b,)"
)
# Adapted from Python 3's Lib/test/test_grammar.py:GrammarTests.testFuncdef
class
TestFunctionAnnotations
(
GrammarTest
):
...
...
@@ -335,6 +407,42 @@ class TestFunctionAnnotations(GrammarTest):
call(*args,)"""
self
.
validate
(
s
)
def
test_13
(
self
):
self
.
validate
(
"def f(a: str, b: int) -> None: call(a, b)"
)
self
.
validate
(
"def f(a: str, b: int,) -> None: call(a, b,)"
)
def
test_14
(
self
):
self
.
validate
(
"def f(a: str, *b: int) -> None: call(a, *b)"
)
self
.
validate
(
"def f(a: str, *b: int,) -> None: call(a, *b,)"
)
def
test_15
(
self
):
self
.
validate
(
"def f(a: str, b: int=1) -> None: call(a, b=1)"
)
self
.
validate
(
"def f(a: str, b: int=1,) -> None: call(a, b=1,)"
)
def
test_16
(
self
):
self
.
validate
(
"def f(a: str, **b: int) -> None: call(a, **b)"
)
self
.
validate
(
"def f(a: str, **b: int,) -> None: call(a, **b,)"
)
def
test_17
(
self
):
self
.
validate
(
"def f(*a: str, b: int=1) -> None: call(*a, b=1)"
)
self
.
validate
(
"def f(*a: str, b: int=1,) -> None: call(*a, b=1,)"
)
def
test_18
(
self
):
self
.
validate
(
"def f(*a: str, **b: int) -> None: call(*a, **b)"
)
self
.
validate
(
"def f(*a: str, **b: int,) -> None: call(*a, **b,)"
)
def
test_19
(
self
):
self
.
validate
(
"def f(*, b: int=1) -> None: call(*b)"
)
self
.
validate
(
"def f(*, b: int=1,) -> None: call(*b,)"
)
def
test_20
(
self
):
self
.
validate
(
"def f(a: str='', b: int=2) -> None: call(a=a, b=2)"
)
self
.
validate
(
"def f(a: str='', b: int=2,) -> None: call(a=a, b=2,)"
)
def
test_21
(
self
):
self
.
validate
(
"def f(a: str='', **b: int) -> None: call(a=a, **b)"
)
self
.
validate
(
"def f(a: str='', **b: int,) -> None: call(a=a, **b,)"
)
# Adapted from Python 3's Lib/test/test_grammar.py:GrammarTests.test_var_annot
class
TestVarAnnotations
(
GrammarTest
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment