Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / lib / python2.4 / test / test_cmath.py
CommitLineData
920dae64
AT
1#! /usr/bin/env python
2""" Simple test script for cmathmodule.c
3 Roger E. Masse
4"""
5import cmath, math
6from test.test_support import verbose, verify, TestFailed
7
8verify(abs(cmath.log(10) - math.log(10)) < 1e-9)
9verify(abs(cmath.log(10,2) - math.log(10,2)) < 1e-9)
10try:
11 cmath.log('a')
12except TypeError:
13 pass
14else:
15 raise TestFailed
16
17try:
18 cmath.log(10, 'a')
19except TypeError:
20 pass
21else:
22 raise TestFailed
23
24
25testdict = {'acos' : 1.0,
26 'acosh' : 1.0,
27 'asin' : 1.0,
28 'asinh' : 1.0,
29 'atan' : 0.2,
30 'atanh' : 0.2,
31 'cos' : 1.0,
32 'cosh' : 1.0,
33 'exp' : 1.0,
34 'log' : 1.0,
35 'log10' : 1.0,
36 'sin' : 1.0,
37 'sinh' : 1.0,
38 'sqrt' : 1.0,
39 'tan' : 1.0,
40 'tanh' : 1.0}
41
42for func in testdict.keys():
43 f = getattr(cmath, func)
44 r = f(testdict[func])
45 if verbose:
46 print 'Calling %s(%f) = %f' % (func, testdict[func], abs(r))
47
48p = cmath.pi
49e = cmath.e
50if verbose:
51 print 'PI = ', abs(p)
52 print 'E = ', abs(e)