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
3a20a5de
Kaydet (Commit)
3a20a5de
authored
Şub 08, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20546: Use specific asserts in int tests.
üst
016a3f33
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
test_long.py
Lib/test/test_long.py
+24
-24
No files found.
Lib/test/test_long.py
Dosyayı görüntüle @
3a20a5de
...
@@ -130,7 +130,7 @@ class LongTest(unittest.TestCase):
...
@@ -130,7 +130,7 @@ class LongTest(unittest.TestCase):
# The sign of the number is also random.
# The sign of the number is also random.
def
getran
(
self
,
ndigits
):
def
getran
(
self
,
ndigits
):
self
.
assert
True
(
ndigits
>
0
)
self
.
assert
Greater
(
ndigits
,
0
)
nbits_hi
=
ndigits
*
SHIFT
nbits_hi
=
ndigits
*
SHIFT
nbits_lo
=
nbits_hi
-
SHIFT
+
1
nbits_lo
=
nbits_hi
-
SHIFT
+
1
answer
=
0
answer
=
0
...
@@ -865,21 +865,21 @@ class LongTest(unittest.TestCase):
...
@@ -865,21 +865,21 @@ class LongTest(unittest.TestCase):
def
test_small_ints
(
self
):
def
test_small_ints
(
self
):
for
i
in
range
(
-
5
,
257
):
for
i
in
range
(
-
5
,
257
):
self
.
assert
True
(
i
is
i
+
0
)
self
.
assert
Is
(
i
,
i
+
0
)
self
.
assert
True
(
i
is
i
*
1
)
self
.
assert
Is
(
i
,
i
*
1
)
self
.
assert
True
(
i
is
i
-
0
)
self
.
assert
Is
(
i
,
i
-
0
)
self
.
assert
True
(
i
is
i
//
1
)
self
.
assert
Is
(
i
,
i
//
1
)
self
.
assert
True
(
i
is
i
&
-
1
)
self
.
assert
Is
(
i
,
i
&
-
1
)
self
.
assert
True
(
i
is
i
|
0
)
self
.
assert
Is
(
i
,
i
|
0
)
self
.
assert
True
(
i
is
i
^
0
)
self
.
assert
Is
(
i
,
i
^
0
)
self
.
assert
True
(
i
is
~~
i
)
self
.
assert
Is
(
i
,
~~
i
)
self
.
assert
True
(
i
is
i
**
1
)
self
.
assert
Is
(
i
,
i
**
1
)
self
.
assert
True
(
i
is
int
(
str
(
i
)))
self
.
assert
Is
(
i
,
int
(
str
(
i
)))
self
.
assert
True
(
i
is
i
<<
2
>>
2
,
str
(
i
))
self
.
assert
Is
(
i
,
i
<<
2
>>
2
,
str
(
i
))
# corner cases
# corner cases
i
=
1
<<
70
i
=
1
<<
70
self
.
assert
True
(
i
-
i
is
0
)
self
.
assert
Is
(
i
-
i
,
0
)
self
.
assert
True
(
0
*
i
is
0
)
self
.
assert
Is
(
0
*
i
,
0
)
def
test_bit_length
(
self
):
def
test_bit_length
(
self
):
tiny
=
1e-10
tiny
=
1e-10
...
@@ -926,7 +926,7 @@ class LongTest(unittest.TestCase):
...
@@ -926,7 +926,7 @@ class LongTest(unittest.TestCase):
got
=
round
(
k
+
offset
,
-
1
)
got
=
round
(
k
+
offset
,
-
1
)
expected
=
v
+
offset
expected
=
v
+
offset
self
.
assertEqual
(
got
,
expected
)
self
.
assertEqual
(
got
,
expected
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
# larger second argument
# larger second argument
self
.
assertEqual
(
round
(
-
150
,
-
2
),
-
200
)
self
.
assertEqual
(
round
(
-
150
,
-
2
),
-
200
)
...
@@ -965,7 +965,7 @@ class LongTest(unittest.TestCase):
...
@@ -965,7 +965,7 @@ class LongTest(unittest.TestCase):
got
=
round
(
10
**
k
+
324678
,
-
3
)
got
=
round
(
10
**
k
+
324678
,
-
3
)
expect
=
10
**
k
+
325000
expect
=
10
**
k
+
325000
self
.
assertEqual
(
got
,
expect
)
self
.
assertEqual
(
got
,
expect
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
# nonnegative second argument: round(x, n) should just return x
# nonnegative second argument: round(x, n) should just return x
for
n
in
range
(
5
):
for
n
in
range
(
5
):
...
@@ -973,7 +973,7 @@ class LongTest(unittest.TestCase):
...
@@ -973,7 +973,7 @@ class LongTest(unittest.TestCase):
x
=
random
.
randrange
(
-
10000
,
10000
)
x
=
random
.
randrange
(
-
10000
,
10000
)
got
=
round
(
x
,
n
)
got
=
round
(
x
,
n
)
self
.
assertEqual
(
got
,
x
)
self
.
assertEqual
(
got
,
x
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
for
huge_n
in
2
**
31
-
1
,
2
**
31
,
2
**
63
-
1
,
2
**
63
,
2
**
100
,
10
**
100
:
for
huge_n
in
2
**
31
-
1
,
2
**
31
,
2
**
63
-
1
,
2
**
63
,
2
**
100
,
10
**
100
:
self
.
assertEqual
(
round
(
8979323
,
huge_n
),
8979323
)
self
.
assertEqual
(
round
(
8979323
,
huge_n
),
8979323
)
...
@@ -982,7 +982,7 @@ class LongTest(unittest.TestCase):
...
@@ -982,7 +982,7 @@ class LongTest(unittest.TestCase):
x
=
random
.
randrange
(
-
10000
,
10000
)
x
=
random
.
randrange
(
-
10000
,
10000
)
got
=
round
(
x
)
got
=
round
(
x
)
self
.
assertEqual
(
got
,
x
)
self
.
assertEqual
(
got
,
x
)
self
.
assert
True
(
type
(
got
)
is
int
)
self
.
assert
Is
(
type
(
got
),
int
)
# bad second argument
# bad second argument
bad_exponents
=
(
'brian'
,
2.0
,
0
j
,
None
)
bad_exponents
=
(
'brian'
,
2.0
,
0
j
,
None
)
...
@@ -1187,15 +1187,15 @@ class LongTest(unittest.TestCase):
...
@@ -1187,15 +1187,15 @@ class LongTest(unittest.TestCase):
class
myint
(
int
):
class
myint
(
int
):
pass
pass
self
.
assert
True
(
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'big'
))
is
myint
)
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'big'
)),
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'big'
),
1
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'big'
),
1
)
self
.
assert
True
(
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'big'
,
signed
=
False
))
is
myint
)
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'big'
,
signed
=
False
))
,
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'big'
,
signed
=
False
),
1
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'big'
,
signed
=
False
),
1
)
self
.
assert
True
(
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'little'
))
is
myint
)
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'little'
)),
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'little'
),
1
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'little'
),
1
)
self
.
assert
True
(
type
(
myint
.
from_bytes
(
self
.
assert
Is
(
type
(
myint
.
from_bytes
(
b
'
\x00
'
,
'little'
,
signed
=
False
))
is
myint
)
b
'
\x00
'
,
'little'
,
signed
=
False
))
,
myint
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'little'
,
signed
=
False
),
1
)
self
.
assertEqual
(
myint
.
from_bytes
(
b
'
\x01
'
,
'little'
,
signed
=
False
),
1
)
self
.
assertEqual
(
self
.
assertEqual
(
int
.
from_bytes
([
255
,
0
,
0
],
'big'
,
signed
=
True
),
-
65536
)
int
.
from_bytes
([
255
,
0
,
0
],
'big'
,
signed
=
True
),
-
65536
)
...
...
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