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
3194d145
Kaydet (Commit)
3194d145
authored
Ock 08, 2010
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Backport some float repr tests that were missed in issue 7117.
üst
96aa3ca2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
test_float.py
Lib/test/test_float.py
+49
-0
No files found.
Lib/test/test_float.py
Dosyayı görüntüle @
3194d145
...
...
@@ -563,6 +563,55 @@ class ReprTestCase(unittest.TestCase):
self
.
assertEqual
(
v
,
eval
(
repr
(
v
)))
floats_file
.
close
()
@unittest.skipUnless
(
getattr
(
sys
,
'float_repr_style'
,
''
)
==
'short'
,
"applies only when using short float repr style"
)
def
test_short_repr
(
self
):
# test short float repr introduced in Python 3.1. One aspect
# of this repr is that we get some degree of str -> float ->
# str roundtripping. In particular, for any numeric string
# containing 15 or fewer significant digits, those exact same
# digits (modulo trailing zeros) should appear in the output.
# No more repr(0.03) -> "0.029999999999999999"!
test_strings
=
[
# output always includes *either* a decimal point and at
# least one digit after that point, or an exponent.
'0.0'
,
'1.0'
,
'0.01'
,
'0.02'
,
'0.03'
,
'0.04'
,
'0.05'
,
'1.23456789'
,
'10.0'
,
'100.0'
,
# values >= 1e16 get an exponent...
'1000000000000000.0'
,
'9999999999999990.0'
,
'1e+16'
,
'1e+17'
,
# ... and so do values < 1e-4
'0.001'
,
'0.001001'
,
'0.00010000000000001'
,
'0.0001'
,
'9.999999999999e-05'
,
'1e-05'
,
# values designed to provoke failure if the FPU rounding
# precision isn't set correctly
'8.72293771110361e+25'
,
'7.47005307342313e+26'
,
'2.86438000439698e+28'
,
'8.89142905246179e+28'
,
'3.08578087079232e+35'
,
]
for
s
in
test_strings
:
negs
=
'-'
+
s
self
.
assertEqual
(
s
,
repr
(
float
(
s
)))
self
.
assertEqual
(
negs
,
repr
(
float
(
negs
)))
@unittest.skipUnless
(
float
.
__getformat__
(
"double"
)
.
startswith
(
"IEEE"
),
"test requires IEEE 754 doubles"
)
class
RoundTestCase
(
unittest
.
TestCase
):
...
...
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