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
f2bf0d2a
Kaydet (Commit)
f2bf0d2a
authored
Ara 02, 2009
tarafından
Eric Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #4482: Add tests for special float value formatting.
üst
34398184
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
test_float.py
Lib/test/test_float.py
+35
-0
No files found.
Lib/test/test_float.py
Dosyayı görüntüle @
f2bf0d2a
...
...
@@ -490,6 +490,41 @@ class RoundTestCase(unittest.TestCase):
self
.
assertAlmostEqual
(
round
(
0.5e22
,
-
22
),
1e22
)
self
.
assertAlmostEqual
(
round
(
1.5e22
,
-
22
),
2e22
)
@unittest.skipUnless
(
float
.
__getformat__
(
"double"
)
.
startswith
(
"IEEE"
),
"test requires IEEE 754 doubles"
)
def
test_format_specials
(
self
):
# Test formatting of nans and infs.
def
test
(
fmt
,
value
,
expected
):
# Test with both % and format().
self
.
assertEqual
(
fmt
%
value
,
expected
,
fmt
)
if
not
'#'
in
fmt
:
# Until issue 7094 is implemented, format() for floats doesn't
# support '#' formatting
fmt
=
fmt
[
1
:]
# strip off the %
self
.
assertEqual
(
format
(
value
,
fmt
),
expected
,
fmt
)
for
fmt
in
[
'
%
e'
,
'
%
f'
,
'
%
g'
,
'
%.0
e'
,
'
%.6
f'
,
'
%.20
g'
,
'
%#
e'
,
'
%#
f'
,
'
%#
g'
,
'
%#.20
e'
,
'
%#.15
f'
,
'
%#.3
g'
]:
pfmt
=
'
%+
'
+
fmt
[
1
:]
sfmt
=
'
%
'
+
fmt
[
1
:]
test
(
fmt
,
INF
,
'inf'
)
test
(
fmt
,
-
INF
,
'-inf'
)
test
(
fmt
,
NAN
,
'nan'
)
test
(
fmt
,
-
NAN
,
'nan'
)
# When asking for a sign, it's always provided. nans are
# always positive.
test
(
pfmt
,
INF
,
'+inf'
)
test
(
pfmt
,
-
INF
,
'-inf'
)
test
(
pfmt
,
NAN
,
'+nan'
)
test
(
pfmt
,
-
NAN
,
'+nan'
)
# When using ' ' for a sign code, only infs can be negative.
# Others have a space.
test
(
sfmt
,
INF
,
' inf'
)
test
(
sfmt
,
-
INF
,
'-inf'
)
test
(
sfmt
,
NAN
,
' nan'
)
test
(
sfmt
,
-
NAN
,
' nan'
)
# Beginning with Python 2.6 float has cross platform compatible
# ways to create and represent inf and nan
...
...
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