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
fc055252
Kaydet (Commit)
fc055252
authored
Şub 03, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20368: Add tests for Tkinter methods exprstring(), exprdouble(),
exprlong() and exprboolean().
üst
3633da23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
135 additions
and
0 deletions
+135
-0
test_tcl.py
Lib/test/test_tcl.py
+135
-0
No files found.
Lib/test/test_tcl.py
Dosyayı görüntüle @
fc055252
...
...
@@ -177,6 +177,141 @@ class TclTest(unittest.TestCase):
# exit code must be zero
self
.
assertEqual
(
f
.
close
(),
None
)
def
test_exprstring
(
self
):
tcl
=
self
.
interp
tcl
.
call
(
'set'
,
'a'
,
3
)
tcl
.
call
(
'set'
,
'b'
,
6
)
def
check
(
expr
,
expected
):
result
=
tcl
.
exprstring
(
expr
)
self
.
assertEqual
(
result
,
expected
)
self
.
assertIsInstance
(
result
,
str
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprstring
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprstring
,
'8.2'
,
'+6'
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprstring
,
b
'8.2 + 6'
)
self
.
assertRaises
(
TclError
,
tcl
.
exprstring
,
'spam'
)
check
(
''
,
'0'
)
check
(
'8.2 + 6'
,
'14.2'
)
check
(
'2**64'
,
str
(
2
**
64
))
check
(
'3.1 + $a'
,
'6.1'
)
check
(
'2 + "$a.$b"'
,
'5.6'
)
check
(
'4*[llength "6 2"]'
,
'8'
)
check
(
'{word one} < "word $a"'
,
'0'
)
check
(
'4*2 < 7'
,
'0'
)
check
(
'hypot($a, 4)'
,
'5.0'
)
check
(
'5 / 4'
,
'1'
)
check
(
'5 / 4.0'
,
'1.25'
)
check
(
'5 / ( [string length "abcd"] + 0.0 )'
,
'1.25'
)
check
(
'20.0/5.0'
,
'4.0'
)
check
(
'"0x03" > "2"'
,
'1'
)
check
(
'[string length "a
\xbd\u20ac
"]'
,
'3'
)
check
(
r'[string length "a\xbd\u20ac"]'
,
'3'
)
check
(
'"abc"'
,
'abc'
)
check
(
'"a
\xbd\u20ac
"'
,
'a
\xbd\u20ac
'
)
check
(
r'"a\xbd\u20ac"'
,
'a
\xbd\u20ac
'
)
def
test_exprdouble
(
self
):
tcl
=
self
.
interp
tcl
.
call
(
'set'
,
'a'
,
3
)
tcl
.
call
(
'set'
,
'b'
,
6
)
def
check
(
expr
,
expected
):
result
=
tcl
.
exprdouble
(
expr
)
self
.
assertEqual
(
result
,
expected
)
self
.
assertIsInstance
(
result
,
float
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprdouble
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprdouble
,
'8.2'
,
'+6'
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprdouble
,
b
'8.2 + 6'
)
self
.
assertRaises
(
TclError
,
tcl
.
exprdouble
,
'spam'
)
check
(
''
,
0.0
)
check
(
'8.2 + 6'
,
14.2
)
check
(
'2**64'
,
float
(
2
**
64
))
check
(
'3.1 + $a'
,
6.1
)
check
(
'2 + "$a.$b"'
,
5.6
)
check
(
'4*[llength "6 2"]'
,
8.0
)
check
(
'{word one} < "word $a"'
,
0.0
)
check
(
'4*2 < 7'
,
0.0
)
check
(
'hypot($a, 4)'
,
5.0
)
check
(
'5 / 4'
,
1.0
)
check
(
'5 / 4.0'
,
1.25
)
check
(
'5 / ( [string length "abcd"] + 0.0 )'
,
1.25
)
check
(
'20.0/5.0'
,
4.0
)
check
(
'"0x03" > "2"'
,
1.0
)
check
(
'[string length "a
\xbd\u20ac
"]'
,
3.0
)
check
(
r'[string length "a\xbd\u20ac"]'
,
3.0
)
self
.
assertRaises
(
TclError
,
tcl
.
exprdouble
,
'"abc"'
)
def
test_exprlong
(
self
):
tcl
=
self
.
interp
tcl
.
call
(
'set'
,
'a'
,
3
)
tcl
.
call
(
'set'
,
'b'
,
6
)
def
check
(
expr
,
expected
):
result
=
tcl
.
exprlong
(
expr
)
self
.
assertEqual
(
result
,
expected
)
self
.
assertIsInstance
(
result
,
int
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprlong
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprlong
,
'8.2'
,
'+6'
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprlong
,
b
'8.2 + 6'
)
self
.
assertRaises
(
TclError
,
tcl
.
exprlong
,
'spam'
)
check
(
''
,
0
)
check
(
'8.2 + 6'
,
14
)
self
.
assertRaises
(
TclError
,
tcl
.
exprlong
,
'2**64'
)
check
(
'3.1 + $a'
,
6
)
check
(
'2 + "$a.$b"'
,
5
)
check
(
'4*[llength "6 2"]'
,
8
)
check
(
'{word one} < "word $a"'
,
0
)
check
(
'4*2 < 7'
,
0
)
check
(
'hypot($a, 4)'
,
5
)
check
(
'5 / 4'
,
1
)
check
(
'5 / 4.0'
,
1
)
check
(
'5 / ( [string length "abcd"] + 0.0 )'
,
1
)
check
(
'20.0/5.0'
,
4
)
check
(
'"0x03" > "2"'
,
1
)
check
(
'[string length "a
\xbd\u20ac
"]'
,
3
)
check
(
r'[string length "a\xbd\u20ac"]'
,
3
)
self
.
assertRaises
(
TclError
,
tcl
.
exprlong
,
'"abc"'
)
def
test_exprboolean
(
self
):
tcl
=
self
.
interp
tcl
.
call
(
'set'
,
'a'
,
3
)
tcl
.
call
(
'set'
,
'b'
,
6
)
def
check
(
expr
,
expected
):
result
=
tcl
.
exprboolean
(
expr
)
self
.
assertEqual
(
result
,
expected
)
self
.
assertIsInstance
(
result
,
int
)
self
.
assertNotIsInstance
(
result
,
bool
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprboolean
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprboolean
,
'8.2'
,
'+6'
)
self
.
assertRaises
(
TypeError
,
tcl
.
exprboolean
,
b
'8.2 + 6'
)
self
.
assertRaises
(
TclError
,
tcl
.
exprboolean
,
'spam'
)
check
(
''
,
False
)
for
value
in
(
'0'
,
'false'
,
'no'
,
'off'
):
check
(
value
,
False
)
check
(
'"
%
s"'
%
value
,
False
)
check
(
'{
%
s}'
%
value
,
False
)
for
value
in
(
'1'
,
'true'
,
'yes'
,
'on'
):
check
(
value
,
True
)
check
(
'"
%
s"'
%
value
,
True
)
check
(
'{
%
s}'
%
value
,
True
)
check
(
'8.2 + 6'
,
True
)
check
(
'2**64'
,
True
)
check
(
'3.1 + $a'
,
True
)
check
(
'2 + "$a.$b"'
,
True
)
check
(
'4*[llength "6 2"]'
,
True
)
check
(
'{word one} < "word $a"'
,
False
)
check
(
'4*2 < 7'
,
False
)
check
(
'hypot($a, 4)'
,
True
)
check
(
'5 / 4'
,
True
)
check
(
'5 / 4.0'
,
True
)
check
(
'5 / ( [string length "abcd"] + 0.0 )'
,
True
)
check
(
'20.0/5.0'
,
True
)
check
(
'"0x03" > "2"'
,
True
)
check
(
'[string length "a
\xbd\u20ac
"]'
,
True
)
check
(
r'[string length "a\xbd\u20ac"]'
,
True
)
self
.
assertRaises
(
TclError
,
tcl
.
exprboolean
,
'"abc"'
)
def
test_passing_values
(
self
):
def
passValue
(
value
):
return
self
.
interp
.
call
(
'set'
,
'_'
,
value
)
...
...
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