diff --git a/test/unittest_analyze.py b/test/unittest_analyze.py index 66ce4c6261dfd9c7a2a52bea8af724141bbe5de4_dGVzdC91bml0dGVzdF9hbmFseXplLnB5..e5e143fdec2ea85de5f995ce50684d31573be3ed_dGVzdC91bml0dGVzdF9hbmFseXplLnB5 100644 --- a/test/unittest_analyze.py +++ b/test/unittest_analyze.py @@ -110,9 +110,10 @@ ('Student', ('Eetype',) ), ('Company', ('Eetype',) ), ('Address', ('Eetype',) ), + ('Eetype', ('Eetype',) ), ) ), 'is_instance_of' : RelationSchema( ( ('Person', ('Eetype',) ), ('Student', ('Eetype',) ), ('Company', ('Eetype',) ), ('Address', ('Eetype',) ), @@ -113,9 +114,10 @@ ) ), 'is_instance_of' : RelationSchema( ( ('Person', ('Eetype',) ), ('Student', ('Eetype',) ), ('Company', ('Eetype',) ), ('Address', ('Eetype',) ), + ('Eetype', ('Eetype',) ), ) ), 'connait' : RelationSchema( (('Person', ('Person',) ), @@ -320,6 +322,48 @@ sols = sorted(node.children[0].solutions) self.assertEquals(sols, [{'X': 'Company'}]) + def test_non_regr_subjobj1(self): + h = self.helper + def type_from_uid(name): + self.assertEquals(name, "Societe") + return 'Eetype' + uid_func_mapping = {'name': type_from_uid} + # constant as rhs of the uid relation + node = h.parse('Any X WHERE X name "Societe", X is ISOBJ, ISSIBJ is X') + h.compute_solutions(node, uid_func_mapping, debug=DEBUG) + sols = sorted(node.children[0].solutions) + self.assertEquals(sols, [{'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Address'}, + {'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Company'}, + {'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Eetype'}, + {'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Person'}, + {'X': 'Eetype', 'ISOBJ': 'Eetype', 'ISSIBJ': 'Student'}]) + + def test_non_regr_subjobj2(self): + h = self.helper + def type_from_uid(name): + self.assertEquals(name, "Societe") + return 'Eetype' + uid_func_mapping = {'name': type_from_uid} + node = h.parse('Any X WHERE X name "Societe", X is ISOBJ, ISSUBJ is X, X is_instance_of ISIOOBJ, ISIOSUBJ is_instance_of X') + h.compute_solutions(node, uid_func_mapping, debug=DEBUG) + select = node.children[0] + sols = sorted(select.solutions) + self.assertEquals(len(sols), 25) + def var_sols(var): + s = set() + for sol in sols: + s.add(sol.get(var)) + return s + self.assertEquals(var_sols('X'), set(('Eetype',))) + self.assertEquals(var_sols('X'), select.defined_vars['X'].stinfo['possibletypes']) + self.assertEquals(var_sols('ISSUBJ'), set(('Address', 'Company', 'Eetype', 'Person', 'Student'))) + self.assertEquals(var_sols('ISSUBJ'), select.defined_vars['ISSUBJ'].stinfo['possibletypes']) + self.assertEquals(var_sols('ISOBJ'), set(('Eetype',))) + self.assertEquals(var_sols('ISOBJ'), select.defined_vars['ISOBJ'].stinfo['possibletypes']) + self.assertEquals(var_sols('ISIOSUBJ'), set(('Address', 'Company', 'Eetype', 'Person', 'Student'))) + self.assertEquals(var_sols('ISIOSUBJ'), select.defined_vars['ISIOSUBJ'].stinfo['possibletypes']) + self.assertEquals(var_sols('ISIOOBJ'), set(('Eetype',))) + self.assertEquals(var_sols('ISIOOBJ'), select.defined_vars['ISIOOBJ'].stinfo['possibletypes']) def test_unusableuid_func_mapping(self): h = self.helper