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
27d445f5
Kaydet (Commit)
27d445f5
authored
Agu 10, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Nannified, and re-indented with 4 spaces.
üst
cc221c47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
88 deletions
+88
-88
test_b1.py
Lib/test/test_b1.py
+88
-88
No files found.
Lib/test/test_b1.py
Dosyayı görüntüle @
27d445f5
...
@@ -25,15 +25,15 @@ if abs(-1234L) <> 1234L: raise TestFailed, 'abs(-1234L)'
...
@@ -25,15 +25,15 @@ if abs(-1234L) <> 1234L: raise TestFailed, 'abs(-1234L)'
print
'apply'
print
'apply'
def
f0
(
*
args
):
def
f0
(
*
args
):
if
args
!=
():
raise
TestFailed
,
'f0 called with '
+
`args`
if
args
!=
():
raise
TestFailed
,
'f0 called with '
+
`args`
def
f1
(
a1
):
def
f1
(
a1
):
if
a1
!=
1
:
raise
TestFailed
,
'f1 called with '
+
`a1`
if
a1
!=
1
:
raise
TestFailed
,
'f1 called with '
+
`a1`
def
f2
(
a1
,
a2
):
def
f2
(
a1
,
a2
):
if
a1
!=
1
or
a2
!=
2
:
if
a1
!=
1
or
a2
!=
2
:
raise
TestFailed
,
'f2 called with '
+
`a1, a2`
raise
TestFailed
,
'f2 called with '
+
`a1, a2`
def
f3
(
a1
,
a2
,
a3
):
def
f3
(
a1
,
a2
,
a3
):
if
a1
!=
1
or
a2
!=
2
or
a3
!=
3
:
if
a1
!=
1
or
a2
!=
2
or
a3
!=
3
:
raise
TestFailed
,
'f3 called with '
+
`a1, a2, a3`
raise
TestFailed
,
'f3 called with '
+
`a1, a2, a3`
apply
(
f0
,
())
apply
(
f0
,
())
apply
(
f1
,
(
1
,))
apply
(
f1
,
(
1
,))
apply
(
f2
,
(
1
,
2
))
apply
(
f2
,
(
1
,
2
))
...
@@ -44,13 +44,13 @@ if not callable(len):raise TestFailed, 'callable(len)'
...
@@ -44,13 +44,13 @@ if not callable(len):raise TestFailed, 'callable(len)'
def
f
():
pass
def
f
():
pass
if
not
callable
(
f
):
raise
TestFailed
,
'callable(f)'
if
not
callable
(
f
):
raise
TestFailed
,
'callable(f)'
class
C
:
class
C
:
def
meth
(
self
):
pass
def
meth
(
self
):
pass
if
not
callable
(
C
):
raise
TestFailed
,
'callable(C)'
if
not
callable
(
C
):
raise
TestFailed
,
'callable(C)'
x
=
C
()
x
=
C
()
if
not
callable
(
x
.
meth
):
raise
TestFailed
,
'callable(x.meth)'
if
not
callable
(
x
.
meth
):
raise
TestFailed
,
'callable(x.meth)'
if
callable
(
x
):
raise
TestFailed
,
'callable(x)'
if
callable
(
x
):
raise
TestFailed
,
'callable(x)'
class
D
(
C
):
class
D
(
C
):
def
__call__
(
self
):
pass
def
__call__
(
self
):
pass
y
=
D
()
y
=
D
()
if
not
callable
(
y
):
raise
TestFailed
,
'callable(y)'
if
not
callable
(
y
):
raise
TestFailed
,
'callable(y)'
...
@@ -127,13 +127,13 @@ if divmod(12L, -7) <> (-2L, -2): raise TestFailed, 'divmod(12L, -7)'
...
@@ -127,13 +127,13 @@ if divmod(12L, -7) <> (-2L, -2): raise TestFailed, 'divmod(12L, -7)'
if
divmod
(
-
12L
,
-
7
)
<>
(
1L
,
-
5
):
raise
TestFailed
,
'divmod(-12L, -7)'
if
divmod
(
-
12L
,
-
7
)
<>
(
1L
,
-
5
):
raise
TestFailed
,
'divmod(-12L, -7)'
#
#
if
fcmp
(
divmod
(
3.25
,
1.0
),
(
3.0
,
0.25
)):
if
fcmp
(
divmod
(
3.25
,
1.0
),
(
3.0
,
0.25
)):
raise
TestFailed
,
'divmod(3.25, 1.0)'
raise
TestFailed
,
'divmod(3.25, 1.0)'
if
fcmp
(
divmod
(
-
3.25
,
1.0
),
(
-
4.0
,
0.75
)):
if
fcmp
(
divmod
(
-
3.25
,
1.0
),
(
-
4.0
,
0.75
)):
raise
TestFailed
,
'divmod(-3.25, 1.0)'
raise
TestFailed
,
'divmod(-3.25, 1.0)'
if
fcmp
(
divmod
(
3.25
,
-
1.0
),
(
-
4.0
,
-
0.75
)):
if
fcmp
(
divmod
(
3.25
,
-
1.0
),
(
-
4.0
,
-
0.75
)):
raise
TestFailed
,
'divmod(3.25, -1.0)'
raise
TestFailed
,
'divmod(3.25, -1.0)'
if
fcmp
(
divmod
(
-
3.25
,
-
1.0
),
(
3.0
,
-
0.25
)):
if
fcmp
(
divmod
(
-
3.25
,
-
1.0
),
(
3.0
,
-
0.25
)):
raise
TestFailed
,
'divmod(-3.25, -1.0)'
raise
TestFailed
,
'divmod(-3.25, -1.0)'
print
'eval'
print
'eval'
if
eval
(
'1+1'
)
<>
2
:
raise
TestFailed
,
'eval(
\'
1+1
\'
)'
if
eval
(
'1+1'
)
<>
2
:
raise
TestFailed
,
'eval(
\'
1+1
\'
)'
...
@@ -163,27 +163,27 @@ unlink(TESTFN)
...
@@ -163,27 +163,27 @@ unlink(TESTFN)
print
'filter'
print
'filter'
if
filter
(
lambda
c
:
'a'
<=
c
<=
'z'
,
'Hello World'
)
<>
'elloorld'
:
if
filter
(
lambda
c
:
'a'
<=
c
<=
'z'
,
'Hello World'
)
<>
'elloorld'
:
raise
TestFailed
,
'filter (filter a string)'
raise
TestFailed
,
'filter (filter a string)'
if
filter
(
None
,
[
1
,
'hello'
,
[],
[
3
],
''
,
None
,
9
,
0
])
<>
[
1
,
'hello'
,
[
3
],
9
]:
if
filter
(
None
,
[
1
,
'hello'
,
[],
[
3
],
''
,
None
,
9
,
0
])
<>
[
1
,
'hello'
,
[
3
],
9
]:
raise
TestFailed
,
'filter (remove false values)'
raise
TestFailed
,
'filter (remove false values)'
if
filter
(
lambda
x
:
x
>
0
,
[
1
,
-
3
,
9
,
0
,
2
])
<>
[
1
,
9
,
2
]:
if
filter
(
lambda
x
:
x
>
0
,
[
1
,
-
3
,
9
,
0
,
2
])
<>
[
1
,
9
,
2
]:
raise
TestFailed
,
'filter (keep positives)'
raise
TestFailed
,
'filter (keep positives)'
class
Squares
:
class
Squares
:
def
__init__
(
self
,
max
):
def
__init__
(
self
,
max
):
self
.
max
=
max
self
.
max
=
max
self
.
sofar
=
[]
self
.
sofar
=
[]
def
__len__
(
self
):
return
len
(
self
.
sofar
)
def
__len__
(
self
):
return
len
(
self
.
sofar
)
def
__getitem__
(
self
,
i
):
def
__getitem__
(
self
,
i
):
if
not
0
<=
i
<
self
.
max
:
raise
IndexError
if
not
0
<=
i
<
self
.
max
:
raise
IndexError
n
=
len
(
self
.
sofar
)
n
=
len
(
self
.
sofar
)
while
n
<=
i
:
while
n
<=
i
:
self
.
sofar
.
append
(
n
*
n
)
self
.
sofar
.
append
(
n
*
n
)
n
=
n
+
1
n
=
n
+
1
return
self
.
sofar
[
i
]
return
self
.
sofar
[
i
]
if
filter
(
None
,
Squares
(
10
))
!=
[
1
,
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
]:
if
filter
(
None
,
Squares
(
10
))
!=
[
1
,
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
]:
raise
TestFailed
,
'filter(None, Squares(10))'
raise
TestFailed
,
'filter(None, Squares(10))'
if
filter
(
lambda
x
:
x
%
2
,
Squares
(
10
))
!=
[
1
,
9
,
25
,
49
,
81
]:
if
filter
(
lambda
x
:
x
%
2
,
Squares
(
10
))
!=
[
1
,
9
,
25
,
49
,
81
]:
raise
TestFailed
,
'filter(oddp, Squares(10))'
raise
TestFailed
,
'filter(oddp, Squares(10))'
print
'float'
print
'float'
if
float
(
3.14
)
<>
3.14
:
raise
TestFailed
,
'float(3.14)'
if
float
(
3.14
)
<>
3.14
:
raise
TestFailed
,
'float(3.14)'
...
@@ -237,35 +237,35 @@ if int(3.5) <> 3: raise TestFailed, 'int(3.5)'
...
@@ -237,35 +237,35 @@ if int(3.5) <> 3: raise TestFailed, 'int(3.5)'
if
int
(
-
3.5
)
<>
-
3
:
raise
TestFailed
,
'int(-3.5)'
if
int
(
-
3.5
)
<>
-
3
:
raise
TestFailed
,
'int(-3.5)'
# Test conversion fron strings and various anomalies
# Test conversion fron strings and various anomalies
L
=
[
L
=
[
(
'0'
,
0
),
(
'0'
,
0
),
(
'1'
,
1
),
(
'1'
,
1
),
(
'9'
,
9
),
(
'9'
,
9
),
(
'10'
,
10
),
(
'10'
,
10
),
(
'99'
,
99
),
(
'99'
,
99
),
(
'100'
,
100
),
(
'100'
,
100
),
(
'314'
,
314
),
(
'314'
,
314
),
(
' 314'
,
314
),
(
' 314'
,
314
),
(
'314 '
,
314
),
(
'314 '
,
314
),
(
'
\t\t
314
\t\t
'
,
314
),
(
'
\t\t
314
\t\t
'
,
314
),
(
`sys.maxint`
,
sys
.
maxint
),
(
`sys.maxint`
,
sys
.
maxint
),
(
''
,
ValueError
),
(
''
,
ValueError
),
(
' '
,
ValueError
),
(
' '
,
ValueError
),
(
'
\t\t
'
,
ValueError
),
(
'
\t\t
'
,
ValueError
),
]
]
for
s
,
v
in
L
:
for
s
,
v
in
L
:
for
sign
in
""
,
"+"
,
"-"
:
for
sign
in
""
,
"+"
,
"-"
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
ss
=
prefix
+
sign
+
s
ss
=
prefix
+
sign
+
s
vv
=
v
vv
=
v
if
sign
==
"-"
and
v
is
not
ValueError
:
if
sign
==
"-"
and
v
is
not
ValueError
:
vv
=
-
v
vv
=
-
v
try
:
try
:
if
int
(
ss
)
!=
vv
:
if
int
(
ss
)
!=
vv
:
raise
TestFailed
,
"int(
%
s)"
%
`ss`
raise
TestFailed
,
"int(
%
s)"
%
`ss`
except
v
:
except
v
:
pass
pass
except
ValueError
,
e
:
except
ValueError
,
e
:
raise
TestFailed
,
"int(
%
s) raised ValueError:
%
s"
%
(
`ss`
,
e
)
raise
TestFailed
,
"int(
%
s) raised ValueError:
%
s"
%
(
`ss`
,
e
)
s
=
`-1-sys.maxint`
s
=
`-1-sys.maxint`
if
int
(
s
)
+
1
!=
-
sys
.
maxint
:
if
int
(
s
)
+
1
!=
-
sys
.
maxint
:
raise
TestFailed
,
"int(
%
s)"
%
`s`
raise
TestFailed
,
"int(
%
s)"
%
`s`
...
@@ -332,61 +332,61 @@ if long(3.5) <> 3L: raise TestFailed, 'long(3.5)'
...
@@ -332,61 +332,61 @@ if long(3.5) <> 3L: raise TestFailed, 'long(3.5)'
if
long
(
-
3.5
)
<>
-
3L
:
raise
TestFailed
,
'long(-3.5)'
if
long
(
-
3.5
)
<>
-
3L
:
raise
TestFailed
,
'long(-3.5)'
# Check conversions from string (same test set as for int(), and then some)
# Check conversions from string (same test set as for int(), and then some)
LL
=
[
LL
=
[
(
'1'
+
'0'
*
20
,
10L
**
20
),
(
'1'
+
'0'
*
20
,
10L
**
20
),
(
'1'
+
'0'
*
100
,
10L
**
100
),
(
'1'
+
'0'
*
100
,
10L
**
100
),
]
]
for
s
,
v
in
L
+
LL
:
for
s
,
v
in
L
+
LL
:
for
sign
in
""
,
"+"
,
"-"
:
for
sign
in
""
,
"+"
,
"-"
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
ss
=
prefix
+
sign
+
s
ss
=
prefix
+
sign
+
s
vv
=
v
vv
=
v
if
sign
==
"-"
and
v
is
not
ValueError
:
if
sign
==
"-"
and
v
is
not
ValueError
:
vv
=
-
v
vv
=
-
v
try
:
try
:
if
long
(
ss
)
!=
long
(
vv
):
if
long
(
ss
)
!=
long
(
vv
):
raise
TestFailed
,
"int(
%
s)"
%
`ss`
raise
TestFailed
,
"int(
%
s)"
%
`ss`
except
v
:
except
v
:
pass
pass
except
ValueError
,
e
:
except
ValueError
,
e
:
raise
TestFailed
,
"int(
%
s) raised ValueError:
%
s"
%
(
`ss`
,
e
)
raise
TestFailed
,
"int(
%
s) raised ValueError:
%
s"
%
(
`ss`
,
e
)
print
'map'
print
'map'
if
map
(
None
,
'hello world'
)
<>
[
'h'
,
'e'
,
'l'
,
'l'
,
'o'
,
' '
,
'w'
,
'o'
,
'r'
,
'l'
,
'd'
]:
if
map
(
None
,
'hello world'
)
<>
[
'h'
,
'e'
,
'l'
,
'l'
,
'o'
,
' '
,
'w'
,
'o'
,
'r'
,
'l'
,
'd'
]:
raise
TestFailed
,
'map(None,
\'
hello world
\'
)'
raise
TestFailed
,
'map(None,
\'
hello world
\'
)'
if
map
(
None
,
'abcd'
,
'efg'
)
<>
\
if
map
(
None
,
'abcd'
,
'efg'
)
<>
\
[(
'a'
,
'e'
),
(
'b'
,
'f'
),
(
'c'
,
'g'
),
(
'd'
,
None
)]:
[(
'a'
,
'e'
),
(
'b'
,
'f'
),
(
'c'
,
'g'
),
(
'd'
,
None
)]:
raise
TestFailed
,
'map(None,
\'
abcd
\'
,
\'
efg
\'
)'
raise
TestFailed
,
'map(None,
\'
abcd
\'
,
\'
efg
\'
)'
if
map
(
None
,
range
(
10
))
<>
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]:
if
map
(
None
,
range
(
10
))
<>
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]:
raise
TestFailed
,
'map(None, range(10))'
raise
TestFailed
,
'map(None, range(10))'
if
map
(
lambda
x
:
x
*
x
,
range
(
1
,
4
))
<>
[
1
,
4
,
9
]:
if
map
(
lambda
x
:
x
*
x
,
range
(
1
,
4
))
<>
[
1
,
4
,
9
]:
raise
TestFailed
,
'map(lambda x: x*x, range(1,4))'
raise
TestFailed
,
'map(lambda x: x*x, range(1,4))'
try
:
try
:
from
math
import
sqrt
from
math
import
sqrt
except
ImportError
:
except
ImportError
:
def
sqrt
(
x
):
def
sqrt
(
x
):
return
pow
(
x
,
0.5
)
return
pow
(
x
,
0.5
)
if
map
(
lambda
x
:
map
(
sqrt
,
x
),
[[
16
,
4
],
[
81
,
9
]])
<>
[[
4.0
,
2.0
],
[
9.0
,
3.0
]]:
if
map
(
lambda
x
:
map
(
sqrt
,
x
),
[[
16
,
4
],
[
81
,
9
]])
<>
[[
4.0
,
2.0
],
[
9.0
,
3.0
]]:
raise
TestFailed
,
'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])'
raise
TestFailed
,
'map(lambda x: map(sqrt,x), [[16, 4], [81, 9]])'
if
map
(
lambda
x
,
y
:
x
+
y
,
[
1
,
3
,
2
],
[
9
,
1
,
4
])
<>
[
10
,
4
,
6
]:
if
map
(
lambda
x
,
y
:
x
+
y
,
[
1
,
3
,
2
],
[
9
,
1
,
4
])
<>
[
10
,
4
,
6
]:
raise
TestFailed
,
'map(lambda x,y: x+y, [1,3,2], [9,1,4])'
raise
TestFailed
,
'map(lambda x,y: x+y, [1,3,2], [9,1,4])'
def
plus
(
*
v
):
def
plus
(
*
v
):
accu
=
0
accu
=
0
for
i
in
v
:
accu
=
accu
+
i
for
i
in
v
:
accu
=
accu
+
i
return
accu
return
accu
if
map
(
plus
,
[
1
,
3
,
7
])
<>
[
1
,
3
,
7
]:
if
map
(
plus
,
[
1
,
3
,
7
])
<>
[
1
,
3
,
7
]:
raise
TestFailed
,
'map(plus, [1, 3, 7])'
raise
TestFailed
,
'map(plus, [1, 3, 7])'
if
map
(
plus
,
[
1
,
3
,
7
],
[
4
,
9
,
2
])
<>
[
1
+
4
,
3
+
9
,
7
+
2
]:
if
map
(
plus
,
[
1
,
3
,
7
],
[
4
,
9
,
2
])
<>
[
1
+
4
,
3
+
9
,
7
+
2
]:
raise
TestFailed
,
'map(plus, [1, 3, 7], [4, 9, 2])'
raise
TestFailed
,
'map(plus, [1, 3, 7], [4, 9, 2])'
if
map
(
plus
,
[
1
,
3
,
7
],
[
4
,
9
,
2
],
[
1
,
1
,
0
])
<>
[
1
+
4
+
1
,
3
+
9
+
1
,
7
+
2
+
0
]:
if
map
(
plus
,
[
1
,
3
,
7
],
[
4
,
9
,
2
],
[
1
,
1
,
0
])
<>
[
1
+
4
+
1
,
3
+
9
+
1
,
7
+
2
+
0
]:
raise
TestFailed
,
'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])'
raise
TestFailed
,
'map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])'
if
map
(
None
,
Squares
(
10
))
!=
[
0
,
1
,
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
]:
if
map
(
None
,
Squares
(
10
))
!=
[
0
,
1
,
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
]:
raise
TestFailed
,
'map(None, Squares(10))'
raise
TestFailed
,
'map(None, Squares(10))'
if
map
(
int
,
Squares
(
10
))
!=
[
0
,
1
,
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
]:
if
map
(
int
,
Squares
(
10
))
!=
[
0
,
1
,
4
,
9
,
16
,
25
,
36
,
49
,
64
,
81
]:
raise
TestFailed
,
'map(int, Squares(10))'
raise
TestFailed
,
'map(int, Squares(10))'
if
map
(
None
,
Squares
(
3
),
Squares
(
2
))
!=
[(
0
,
0
),
(
1
,
1
),
(
4
,
None
)]:
if
map
(
None
,
Squares
(
3
),
Squares
(
2
))
!=
[(
0
,
0
),
(
1
,
1
),
(
4
,
None
)]:
raise
TestFailed
,
'map(None, Squares(3), Squares(2))'
raise
TestFailed
,
'map(None, Squares(3), Squares(2))'
if
map
(
max
,
Squares
(
3
),
Squares
(
2
))
!=
[
0
,
1
,
None
]:
if
map
(
max
,
Squares
(
3
),
Squares
(
2
))
!=
[
0
,
1
,
None
]:
raise
TestFailed
,
'map(max, Squares(3), Squares(2))'
raise
TestFailed
,
'map(max, Squares(3), Squares(2))'
print
'max'
print
'max'
if
max
(
'123123'
)
<>
'3'
:
raise
TestFailed
,
'max(
\'
123123
\'
)'
if
max
(
'123123'
)
<>
'3'
:
raise
TestFailed
,
'max(
\'
123123
\'
)'
...
...
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