ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/py_tests/test_ev.py
Revision: 1.3
Committed: Mon Mar 28 17:48:43 2016 UTC (9 years, 2 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
Refactoring of test suite, use independently of SCons and with Py2.7 or 3.x.

File Contents

# User Rev Content
1 schorsch 1.1
2     import os
3     import math
4     import string
5     import unittest
6    
7     from unit_tools import support
8     from unit_tools import lcompare
9    
10 schorsch 1.2 _bindir = None
11    
12 schorsch 1.1 class EvTestCase(unittest.TestCase):
13     def setUp(self):
14 schorsch 1.2 if _bindir:
15     self.oldpath = os.environ['PATH']
16     os.environ['PATH'] = _bindir
17 schorsch 1.1
18     def tearDown(self):
19 schorsch 1.2 if _bindir:
20     os.environ['PATH'] = self.oldpath
21 schorsch 1.1
22     ltest = [
23     ['2.3 + 5 * 21.7 / 1.43', [2.3 + 5 * 21.7 / 1.43]],
24     ['if(1, 1, 0)', [1]],
25     ['if(0, 1, 0)', [0]],
26     ['select(3, 1, 2, 3, 4, 5)', [3]],
27     ['floor(5.743)', [5]],
28     ['ceil(5.743)', [6]],
29     ['sqrt(7.4)', [math.sqrt(7.4)]],
30     ['exp(3.4)', [math.exp(3.4)]],
31     ['log(2.4)', [math.log(2.4)]],
32     ['log10(5.4)', [math.log10(5.4)]],
33     ['sin(.51)', [math.sin(.51)]],
34     ['cos(.41)', [math.cos(.41)]],
35     ['tan(0.77)', [math.tan(0.77)]],
36     ['asin(0.83)', [math.asin(0.83)]],
37     ['acos(.94)', [math.acos(.94)]],
38     ['atan(0.22)', [math.atan(0.22)]],
39     ['atan2(0.72, 0.54)', [math.atan2(0.72, 0.54)]],
40     ]
41    
42     def test_singleres(self):
43     for expr, expect in self.ltest:
44     cmd = 'ev "%s"' % expr
45     result = [string.strip(os.popen(cmd).read())]
46     try: lcompare.lcompare(result, expect)
47     except lcompare.error, e:
48     self.fail('%s [%s]' % (str(e),cmd))
49    
50     def test_multipleres(self):
51     pass # XXX implement
52    
53 schorsch 1.2 def main(bindir=None):
54     global _bindir
55     _bindir=bindir
56 schorsch 1.1 support.run_case(EvTestCase)
57    
58     if __name__ == '__main__':
59     main()
60    
61     # vi: set ts=4 sw=4 :