tests/float: Convert "sys.exit()" to "raise SystemExit".

The latter is shorter and simpler because it doesn't require importing the
sys module.
This commit is contained in:
Damien George 2017-06-08 14:00:57 +10:00
parent d80c951f71
commit fde54350a8
13 changed files with 13 additions and 26 deletions

View File

@ -3,9 +3,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(array('f', array('h', [1, 2]))) print(array('f', array('h', [1, 2])))
print(array('d', array('f', [1, 2]))) print(array('d', array('f', [1, 2])))

View File

@ -3,9 +3,8 @@ try:
min min
max max
except: except:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(min(0,1.0)) print(min(0,1.0))
print(min(1.0,0)) print(min(1.0,0))

View File

@ -3,8 +3,7 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(bytearray(array('f', [1, 2.3]))) print(bytearray(array('f', [1, 2.3])))

View File

@ -3,8 +3,7 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
print(bytes(array('f', [1, 2.3]))) print(bytes(array('f', [1, 2.3])))

View File

@ -4,8 +4,7 @@ try:
from cmath import * from cmath import *
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
# make sure these constants exist in cmath # make sure these constants exist in cmath
print("%.5g" % e) print("%.5g" % e)

View File

@ -5,8 +5,7 @@ try:
log10 log10
except (ImportError, NameError): except (ImportError, NameError):
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
test_values_non_zero = [] test_values_non_zero = []
base_values = (0.0, 0.5, 1.2345, 10.) base_values = (0.0, 0.5, 1.2345, 10.)

View File

@ -1,9 +1,8 @@
try: try:
from array import array from array import array
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
def test(a): def test(a):
print(a) print(a)

View File

@ -5,9 +5,8 @@ try:
except: except:
import struct import struct
except ImportError: except ImportError:
import sys
print("SKIP") print("SKIP")
sys.exit() raise SystemExit
i = 1. + 1/2 i = 1. + 1/2
# TODO: it looks like '=' format modifier is not yet supported # TODO: it looks like '=' format modifier is not yet supported

View File

@ -4,8 +4,7 @@ try:
from math import * from math import *
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.] test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.]
test_values_small = [-10., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 10.] # so we don't overflow 32-bit precision test_values_small = [-10., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 10.] # so we don't overflow 32-bit precision

View File

@ -4,8 +4,7 @@ try:
from math import isfinite, isnan, isinf from math import isfinite, isnan, isinf
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'), test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'),
-float('NaN'), -float('Inf')] -float('NaN'), -float('Inf')]

View File

@ -4,8 +4,7 @@ try:
import math import math
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
for fun in (math.ceil, math.floor, math.trunc): for fun in (math.ceil, math.floor, math.trunc):
for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')): for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')):

View File

@ -4,8 +4,7 @@ try:
import math import math
except ImportError: except ImportError:
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
for fun in (math.ceil, math.floor, math.trunc): for fun in (math.ceil, math.floor, math.trunc):
for x in (-1e25, 1e25): for x in (-1e25, 1e25):

View File

@ -5,8 +5,7 @@ try:
erf erf
except (ImportError, NameError): except (ImportError, NameError):
print("SKIP") print("SKIP")
import sys raise SystemExit
sys.exit()
test_values = [-8., -2.5, -1, -0.5, 0.0, 0.5, 2.5, 8.,] test_values = [-8., -2.5, -1, -0.5, 0.0, 0.5, 2.5, 8.,]
pos_test_values = [0.001, 0.1, 0.5, 1.0, 1.5, 10.,] pos_test_values = [0.001, 0.1, 0.5, 1.0, 1.5, 10.,]