mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
This patch removes all uses of "assert" in the regression test suite
and replaces them with a new API verify(). As a result the regression suite will also perform its tests in optimization mode. Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
This commit is contained in:
parent
8551dd6078
commit
3661908a6a
70 changed files with 436 additions and 412 deletions
|
@ -1,4 +1,4 @@
|
|||
from test_support import TestFailed, verbose
|
||||
from test_support import verify, verbose, TestFailed
|
||||
from string import join
|
||||
from random import random, randint
|
||||
|
||||
|
@ -41,7 +41,7 @@ def check(ok, *args):
|
|||
# The sign of the number is also random.
|
||||
|
||||
def getran(ndigits):
|
||||
assert ndigits > 0
|
||||
verify(ndigits > 0)
|
||||
nbits_hi = ndigits * SHIFT
|
||||
nbits_lo = nbits_hi - SHIFT + 1
|
||||
answer = 0L
|
||||
|
@ -50,13 +50,13 @@ def getran(ndigits):
|
|||
while nbits < nbits_lo:
|
||||
bits = (r >> 1) + 1
|
||||
bits = min(bits, nbits_hi - nbits)
|
||||
assert 1 <= bits <= SHIFT
|
||||
verify(1 <= bits <= SHIFT)
|
||||
nbits = nbits + bits
|
||||
answer = answer << bits
|
||||
if r & 1:
|
||||
answer = answer | ((1 << bits) - 1)
|
||||
r = int(random() * (SHIFT * 2))
|
||||
assert nbits_lo <= nbits <= nbits_hi
|
||||
verify(nbits_lo <= nbits <= nbits_hi)
|
||||
if random() < 0.5:
|
||||
answer = -answer
|
||||
return answer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue