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
08a64039
Kaydet (Commit)
08a64039
authored
Agu 12, 2001
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Test the unary operator changes to the compiler
üst
f73e30c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
test_unary.py
Lib/test/test_unary.py
+43
-0
No files found.
Lib/test/test_unary.py
0 → 100644
Dosyayı görüntüle @
08a64039
"""Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2"""
import
unittest
from
test_support
import
run_unittest
class
UnaryOpTestCase
(
unittest
.
TestCase
):
def
test_negative
(
self
):
self
.
assert_
(
-
2
==
0
-
2
)
self
.
assert_
(
-
0
==
0
)
self
.
assert_
(
--
2
==
2
)
self
.
assert_
(
-
2L
==
0
-
2L
)
self
.
assert_
(
-
2.0
==
0
-
2.0
)
self
.
assert_
(
-
2
j
==
0
-
2
j
)
def
test_positive
(
self
):
self
.
assert_
(
+
2
==
2
)
self
.
assert_
(
+
0
==
0
)
self
.
assert_
(
++
2
==
2
)
self
.
assert_
(
+
2L
==
2L
)
self
.
assert_
(
+
2.0
==
2.0
)
self
.
assert_
(
+
2
j
==
2
j
)
def
test_invert
(
self
):
self
.
assert_
(
-
2
==
0
-
2
)
self
.
assert_
(
-
0
==
0
)
self
.
assert_
(
--
2
==
2
)
self
.
assert_
(
-
2L
==
0
-
2L
)
def
test_overflow
(
self
):
self
.
assertRaises
(
OverflowError
,
eval
,
"+"
+
(
"9"
*
32
))
self
.
assertRaises
(
OverflowError
,
eval
,
"-"
+
(
"9"
*
32
))
self
.
assertRaises
(
OverflowError
,
eval
,
"~"
+
(
"9"
*
32
))
def
test_bad_types
(
self
):
for
op
in
'+'
,
'-'
,
'~'
:
self
.
assertRaises
(
TypeError
,
eval
,
op
+
"'a'"
)
self
.
assertRaises
(
TypeError
,
eval
,
op
+
"u'a'"
)
self
.
assertRaises
(
TypeError
,
eval
,
"~2j"
)
self
.
assertRaises
(
TypeError
,
eval
,
"~2.0"
)
run_unittest
(
UnaryOpTestCase
)
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