* Fix bug in tzparse.py for DST timezone

* Added whatis command to pdb.py
* new module GET.py (GL definitions from <gl/get.h>)
* rect.py: is_empty takes a rect as argument, not two points.
* Added tests for builtin round() [XXX not yet complete!]
This commit is contained in:
Guido van Rossum 1993-03-29 11:30:50 +00:00
parent 04321d1e47
commit e7113b6b3d
7 changed files with 51 additions and 9 deletions

View File

@ -17,7 +17,8 @@ empty = (0, 0), (0, 0)
# Check if a rectangle is empty.
#
def is_empty((left, top), (right, bottom)):
def is_empty(r):
(left, top), (right, bottom) = r
return left >= right or top >= bottom
@ -36,7 +37,7 @@ def intersect(list):
if top < t: top = t
if right > r: right = r
if bottom > b: bottom = b
if is_empty((left, top), (right, bottom)):
if is_empty(((left, top), (right, bottom))):
return empty
return (left, top), (right, bottom)
@ -47,7 +48,7 @@ def intersect(list):
def union(list):
(left, top), (right, bottom) = empty
for (l, t), (r, b) in list[1:]:
if not is_empty((l, t), (r, b)):
if not is_empty(((l, t), (r, b))):
if l < left: left = l
if t < top: top = t
if r > right: right = r

View File

@ -17,7 +17,8 @@ empty = (0, 0), (0, 0)
# Check if a rectangle is empty.
#
def is_empty((left, top), (right, bottom)):
def is_empty(r):
(left, top), (right, bottom) = r
return left >= right or top >= bottom
@ -36,7 +37,7 @@ def intersect(list):
if top < t: top = t
if right > r: right = r
if bottom > b: bottom = b
if is_empty((left, top), (right, bottom)):
if is_empty(((left, top), (right, bottom))):
return empty
return (left, top), (right, bottom)
@ -47,7 +48,7 @@ def intersect(list):
def union(list):
(left, top), (right, bottom) = empty
for (l, t), (r, b) in list[1:]:
if not is_empty((l, t), (r, b)):
if not is_empty(((l, t), (r, b))):
if l < left: left = l
if t < top: top = t
if r > right: right = r

View File

@ -1,6 +1,8 @@
# module 'string' -- A collection of string operations
# XXX Some of these operations are incredibly slow and should be built in
# Warning: most of the code you see here isn't normally used nowadays.
# At the end of this file most functions are replaced by built-in
# functions imported from built-in module "strop".
# Some strings for ctype-style character classification
whitespace = ' \t\n'

View File

@ -1,6 +1,8 @@
# module 'string' -- A collection of string operations
# XXX Some of these operations are incredibly slow and should be built in
# Warning: most of the code you see here isn't normally used nowadays.
# At the end of this file most functions are replaced by built-in
# functions imported from built-in module "strop".
# Some strings for ctype-style character classification
whitespace = ' \t\n'

View File

@ -123,6 +123,41 @@ if repr(()) <> '()': raise TestFailed, 'repr(())'
if repr([]) <> '[]': raise TestFailed, 'repr([])'
if repr({}) <> '{}': raise TestFailed, 'repr({})'
print 'round'
if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)'
if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)'
if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)'
if round(1000000000.0) <> 1000000000.0:
raise TestFailed, 'round(1000000000.0)'
if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)'
if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)'
if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)'
if round(-1000000000.0) <> -1000000000.0:
raise TestFailed, 'round(-1000000000.0)'
if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)'
if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)'
if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)'
if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)'
if round(1000000000.1) <> 1000000000.0:
raise TestFailed, 'round(1000000000.0)'
if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)'
if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)'
if round(-1000000000.1) <> -1000000000.0:
raise TestFailed, 'round(-1000000000.0)'
if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)'
if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)'
if round(999999999.9) <> 1000000000.0:
raise TestFailed, 'round(999999999.9)'
if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)'
if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)'
if round(-999999999.9) <> -1000000000.0:
raise TestFailed, 'round(-999999999.9)'
print 'setattr'
import sys
setattr(sys, 'foobar', 1)

View File

@ -92,6 +92,7 @@ testing
testing
reload
repr
round
setattr
str
type

View File

@ -40,7 +40,7 @@ def tzset():
tzstr = os.environ['TZ']
tzparams = tzparse(tzstr)
timezone = tzparams[1] * 3600
altzone = timezone + 3600
altzone = timezone - 3600
daylight = 1
tzname = tzparams[0], tzparams[2]