summaryrefslogtreecommitdiff
path: root/sys/lib/python/test/test_cmath.py
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-03 11:25:13 +0000
commit458120dd40db6b4df55a4e96b650e16798ef06a0 (patch)
tree8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/lib/python/test/test_cmath.py
parent3a742c699f6806c1145aea5149bf15de15a0afd7 (diff)
add hg and python
Diffstat (limited to 'sys/lib/python/test/test_cmath.py')
-rwxr-xr-xsys/lib/python/test/test_cmath.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/sys/lib/python/test/test_cmath.py b/sys/lib/python/test/test_cmath.py
new file mode 100755
index 000000000..6e392928c
--- /dev/null
+++ b/sys/lib/python/test/test_cmath.py
@@ -0,0 +1,52 @@
+#! /usr/bin/env python
+""" Simple test script for cmathmodule.c
+ Roger E. Masse
+"""
+import cmath, math
+from test.test_support import verbose, verify, TestFailed
+
+verify(abs(cmath.log(10) - math.log(10)) < 1e-9)
+verify(abs(cmath.log(10,2) - math.log(10,2)) < 1e-9)
+try:
+ cmath.log('a')
+except TypeError:
+ pass
+else:
+ raise TestFailed
+
+try:
+ cmath.log(10, 'a')
+except TypeError:
+ pass
+else:
+ raise TestFailed
+
+
+testdict = {'acos' : 1.0,
+ 'acosh' : 1.0,
+ 'asin' : 1.0,
+ 'asinh' : 1.0,
+ 'atan' : 0.2,
+ 'atanh' : 0.2,
+ 'cos' : 1.0,
+ 'cosh' : 1.0,
+ 'exp' : 1.0,
+ 'log' : 1.0,
+ 'log10' : 1.0,
+ 'sin' : 1.0,
+ 'sinh' : 1.0,
+ 'sqrt' : 1.0,
+ 'tan' : 1.0,
+ 'tanh' : 1.0}
+
+for func in testdict.keys():
+ f = getattr(cmath, func)
+ r = f(testdict[func])
+ if verbose:
+ print 'Calling %s(%f) = %f' % (func, testdict[func], abs(r))
+
+p = cmath.pi
+e = cmath.e
+if verbose:
+ print 'PI = ', abs(p)
+ print 'E = ', abs(e)