mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Add tests for float() and complex() with string args (Nick/Stephanie
Lockwood).
This commit is contained in:
parent
cb1f2420ea
commit
52a0d7d802
1 changed files with 2 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ if complex(0j, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0j, 3.14j)'
|
||||||
if complex(0.0, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)'
|
if complex(0.0, 3.14j) <> -3.14+0j: raise TestFailed, 'complex(0.0, 3.14j)'
|
||||||
if complex(0j, 3.14) <> 3.14j: raise TestFailed, 'complex(0j, 3.14)'
|
if complex(0j, 3.14) <> 3.14j: raise TestFailed, 'complex(0j, 3.14)'
|
||||||
if complex(0.0, 3.14) <> 3.14j: raise TestFailed, 'complex(0.0, 3.14)'
|
if complex(0.0, 3.14) <> 3.14j: raise TestFailed, 'complex(0.0, 3.14)'
|
||||||
|
if complex(" 3.14+J ") <> 3.14+1j: raise TestFailed, 'complex(" 3.14+J )"'
|
||||||
class Z:
|
class Z:
|
||||||
def __complex__(self): return 3.14j
|
def __complex__(self): return 3.14j
|
||||||
z = Z()
|
z = Z()
|
||||||
|
|
@ -206,6 +207,7 @@ print 'float'
|
||||||
if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)'
|
if float(3.14) <> 3.14: raise TestFailed, 'float(3.14)'
|
||||||
if float(314) <> 314.0: raise TestFailed, 'float(314)'
|
if float(314) <> 314.0: raise TestFailed, 'float(314)'
|
||||||
if float(314L) <> 314.0: raise TestFailed, 'float(314L)'
|
if float(314L) <> 314.0: raise TestFailed, 'float(314L)'
|
||||||
|
if float(" 3.14 ") <> 3.14: raise TestFailed, 'float(" 3.14 ")'
|
||||||
|
|
||||||
print 'getattr'
|
print 'getattr'
|
||||||
import sys
|
import sys
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue