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
35fb82a3
Kaydet (Commit)
35fb82a3
authored
Ock 26, 1993
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
* os.py: _exit doesn't exist in all variations of posix
* Added fcmp() to test_support.py and use it in test*.py
üst
93f07400
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
19 deletions
+45
-19
os.py
Lib/os.py
+4
-1
test_b1.py
Lib/test/test_b1.py
+10
-6
test_b2.py
Lib/test/test_b2.py
+12
-12
test_support.py
Lib/test/test_support.py
+19
-0
No files found.
Lib/os.py
Dosyayı görüntüle @
35fb82a3
...
...
@@ -18,7 +18,10 @@
try
:
from
posix
import
*
from
posix
import
_exit
try
:
from
posix
import
_exit
except
ImportError
:
pass
name
=
'posix'
curdir
=
'.'
pardir
=
'..'
...
...
Lib/test/test_b1.py
Dosyayı görüntüle @
35fb82a3
...
...
@@ -42,9 +42,9 @@ if cmp(1, -1) <> 1: raise TestFailed, 'cmp(1, -1)'
if
cmp
(
1
,
1
)
<>
0
:
raise
TestFailed
,
'cmp(1, 1)'
print
'coerce'
if
coerce
(
1
,
1.1
)
<>
(
1.0
,
1.1
):
raise
TestFailed
,
'coerce(1, 1.1)'
if
fcmp
(
coerce
(
1
,
1.1
),
(
1.0
,
1.1
)
):
raise
TestFailed
,
'coerce(1, 1.1)'
if
coerce
(
1
,
1L
)
<>
(
1L
,
1L
):
raise
TestFailed
,
'coerce(1, 1L)'
if
coerce
(
1L
,
1.1
)
<>
(
1.0
,
1.1
):
raise
TestFailed
,
'coerce(1L, 1.1)'
if
fcmp
(
coerce
(
1L
,
1.1
),
(
1.0
,
1.1
)
):
raise
TestFailed
,
'coerce(1L, 1.1)'
print
'dir'
x
=
1
...
...
@@ -68,10 +68,14 @@ if divmod(-12, 7L) <> (-2, 2L): raise TestFailed, 'divmod(-12, 7L)'
if
divmod
(
12L
,
-
7
)
<>
(
-
2L
,
-
2
):
raise
TestFailed
,
'divmod(12L, -7)'
if
divmod
(
-
12L
,
-
7
)
<>
(
1L
,
-
5
):
raise
TestFailed
,
'divmod(-12L, -7)'
#
if
divmod
(
3.25
,
1.0
)
<>
(
3.0
,
0.25
):
raise
TestFailed
,
'divmod(3.25, 1.0)'
if
divmod
(
-
3.25
,
1.0
)
<>
(
-
4.0
,
0.75
):
raise
TestFailed
,
'divmod(-3.25, 1.0)'
if
divmod
(
3.25
,
-
1.0
)
<>
(
-
4.0
,
-
0.75
):
raise
TestFailed
,
'divmod(3.25, -1.0)'
if
divmod
(
-
3.25
,
-
1.0
)
<>
(
3.0
,
-
0.25
):
raise
TestFailed
,
'divmod(-3.25, -1.0)'
if
fcmp
(
divmod
(
3.25
,
1.0
),
(
3.0
,
0.25
)):
raise
TestFailed
,
'divmod(3.25, 1.0)'
if
fcmp
(
divmod
(
-
3.25
,
1.0
),
(
-
4.0
,
0.75
)):
raise
TestFailed
,
'divmod(-3.25, 1.0)'
if
fcmp
(
divmod
(
3.25
,
-
1.0
),
(
-
4.0
,
-
0.75
)):
raise
TestFailed
,
'divmod(3.25, -1.0)'
if
fcmp
(
divmod
(
-
3.25
,
-
1.0
),
(
3.0
,
-
0.25
)):
raise
TestFailed
,
'divmod(-3.25, -1.0)'
print
'eval'
if
eval
(
'1+1'
)
<>
2
:
raise
TestFailed
,
'eval(
\'
1+1
\'
)'
...
...
Lib/test/test_b2.py
Dosyayı görüntüle @
35fb82a3
...
...
@@ -71,21 +71,21 @@ if pow(-2L,1) <> -2: raise TestFailed, 'pow(-2L,1)'
if
pow
(
-
2L
,
2
)
<>
4
:
raise
TestFailed
,
'pow(-2L,2)'
if
pow
(
-
2L
,
3
)
<>
-
8
:
raise
TestFailed
,
'pow(-2L,3)'
#
if
pow
(
0.
,
0
)
<>
1.
:
raise
TestFailed
,
'pow(0.,0)'
if
pow
(
0.
,
1
)
<>
0.
:
raise
TestFailed
,
'pow(0.,1)'
if
pow
(
1.
,
0
)
<>
1.
:
raise
TestFailed
,
'pow(1.,0)'
if
pow
(
1.
,
1
)
<>
1.
:
raise
TestFailed
,
'pow(1.,1)'
if
fcmp
(
pow
(
0.
,
0
),
1.
)
:
raise
TestFailed
,
'pow(0.,0)'
if
fcmp
(
pow
(
0.
,
1
),
0.
)
:
raise
TestFailed
,
'pow(0.,1)'
if
fcmp
(
pow
(
1.
,
0
),
1.
)
:
raise
TestFailed
,
'pow(1.,0)'
if
fcmp
(
pow
(
1.
,
1
),
1.
)
:
raise
TestFailed
,
'pow(1.,1)'
#
if
pow
(
2.
,
0
)
<>
1.
:
raise
TestFailed
,
'pow(2.,0)'
if
pow
(
2.
,
10
)
<>
1024.
:
raise
TestFailed
,
'pow(2.,10)'
if
pow
(
2.
,
20
)
<>
1024.
*
1024.
:
raise
TestFailed
,
'pow(2.,20)'
if
pow
(
2.
,
30
)
<>
1024.
*
1024.
*
1024.
:
raise
TestFailed
,
'pow(2.,30)'
if
fcmp
(
pow
(
2.
,
0
),
1.
)
:
raise
TestFailed
,
'pow(2.,0)'
if
fcmp
(
pow
(
2.
,
10
),
1024.
)
:
raise
TestFailed
,
'pow(2.,10)'
if
fcmp
(
pow
(
2.
,
20
),
1024.
*
1024.
)
:
raise
TestFailed
,
'pow(2.,20)'
if
fcmp
(
pow
(
2.
,
30
),
1024.
*
1024.
*
1024.
)
:
raise
TestFailed
,
'pow(2.,30)'
#
# XXX These don't work -- negative float to the float power...
#if
pow(-2.,0) <> 1.
: raise TestFailed, 'pow(-2.,0)'
#if
pow(-2.,1) <> -2.
: raise TestFailed, 'pow(-2.,1)'
#if
pow(-2.,2) <> 4.
: raise TestFailed, 'pow(-2.,2)'
#if
pow(-2.,3) <> -8.
: raise TestFailed, 'pow(-2.,3)'
#if
fcmp(pow(-2.,0), 1.)
: raise TestFailed, 'pow(-2.,0)'
#if
fcmp(pow(-2.,1), -2.)
: raise TestFailed, 'pow(-2.,1)'
#if
fcmp(pow(-2.,2), 4.)
: raise TestFailed, 'pow(-2.,2)'
#if
fcmp(pow(-2.,3), -8.)
: raise TestFailed, 'pow(-2.,3)'
print
'range'
if
range
(
3
)
<>
[
0
,
1
,
2
]:
raise
TestFailed
,
'range(3)'
...
...
Lib/test/test_support.py
Dosyayı görüntüle @
35fb82a3
...
...
@@ -18,5 +18,24 @@ def forget(modname):
except
os
.
error
:
pass
FUZZ
=
1e-6
def
fcmp
(
x
,
y
):
# fuzzy comparison function
if
type
(
x
)
==
type
(
0.0
)
or
type
(
y
)
==
type
(
0.0
):
try
:
x
,
y
=
coerce
(
x
,
y
)
fuzz
=
(
abs
(
x
)
+
abs
(
y
))
*
FUZZ
if
abs
(
x
-
y
)
<=
fuzz
:
return
0
except
:
pass
elif
type
(
x
)
==
type
(
y
)
and
type
(
x
)
in
(
type
(()),
type
([])):
for
i
in
range
(
min
(
len
(
x
),
len
(
y
))):
outcome
=
fcmp
(
x
[
i
],
y
[
i
])
if
outcome
<>
0
:
return
outcome
return
cmp
(
len
(
x
),
len
(
y
))
return
cmp
(
x
,
y
)
TESTFN
=
'@test'
# Filename used for testing
from
os
import
unlink
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