1+ import unittest
2+ import sys
3+ import os
4+
5+ # Add the project root to Python's module search path
6+ sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." )))
7+
8+ import aika
9+
10+ class ExponentialFunctionTestCase (unittest .TestCase ):
11+
12+ def testExponentialFunction (self ):
13+ print ("Module 'aika' was loaded from:" , aika .__file__ )
14+
15+ TEST_RELATION_FROM = aika .RelationOne (1 , "TEST_FROM" )
16+ TEST_RELATION_TO = aika .RelationOne (2 , "TEST_TO" )
17+ TEST_RELATION_TO .setReversed (TEST_RELATION_FROM )
18+ TEST_RELATION_FROM .setReversed (TEST_RELATION_TO )
19+
20+ registry = aika .TypeRegistry ()
21+
22+ typeA = aika .TestType (registry , "A" )
23+ typeB = aika .TestType (registry , "B" )
24+
25+ a = typeA .inputField ("a" )
26+
27+ exp_func = typeB .exp ("exp_func" )
28+
29+ exp_func .input (TEST_RELATION_FROM , a , 0 )
30+
31+ registry .flattenTypeHierarchy ()
32+
33+ oa = typeA .instantiate ()
34+ ob = typeB .instantiate ()
35+
36+ aika .TestObj .linkObjects (oa , ob )
37+ ob .initFields ()
38+
39+ oa .setFieldValue (a , 5.0 )
40+
41+ expected_value = 148.413159102576603
42+ actual_value = ob .getFieldValue (exp_func )
43+ print ("ob.getFieldValue(exp_func):" , actual_value )
44+
45+ self .assertAlmostEqual (expected_value , actual_value , places = 5 )
46+
47+ if __name__ == '__main__' :
48+ unittest .main ()
0 commit comments