Exemplo n.º 1
0
    def test_get_dataexp_type(self):
        ast = sync.process('synch a (a | b){\
store ?v.a j;\
start {\
    on:\
        a.?v(y, w || t) & [t+w]{\
            set j = \'w || z:[0];\
        }\
}}')
        symtab = ast.decls.symtab
        j_ent = symtab.get('j')
        self.assertFalse(j_ent is None)
        # { 'y':$__var_5dvq8z, 'z':Int(0), 't':Int(0), 'w':Int(0) }
        self.assertTrue(len(j_ent.type.labels) == 4)
        self.assertTrue('y' in j_ent.type.labels)
        self.assertTrue('z' in j_ent.type.labels)
        self.assertTrue(j_ent.type.labels['z'].show() == "Int(0)")
        self.assertTrue('t' in j_ent.type.labels)
        self.assertTrue(j_ent.type.labels['t'].show() == "Int(0)")
        self.assertTrue('w' in j_ent.type.labels)
        self.assertTrue(j_ent.type.labels['w'].show() == "Int(0)")
        self.assertTrue(len(j_ent.type.tails) == 0)

        st = AstSymtab()
        st.traverse(ast)
        symtabs = st.l
        this_ent = symtabs[0].get('this')
        self.assertFalse(this_ent is None)
        self.assertTrue(len(this_ent.type.labels) == 3)
        self.assertTrue('y' in this_ent.type.labels)
        self.assertTrue('t' in this_ent.type.labels)
        self.assertTrue(this_ent.type.labels['t'].show() == "Int(0)")
        self.assertTrue('w' in this_ent.type.labels)
        self.assertTrue(this_ent.type.labels['w'].show() == "Int(0)")
        self.assertTrue(len(this_ent.type.tails) == 0)
Exemplo n.º 2
0
    def test_check_data_exp_assign(self):
        ast = sync.process('synch id (a | b) {\
store a j;\
start {\
    on:\
        a {\
            set j = this || x:[1];\
        }\
}}')
        symtab = ast.decls.symtab
        j_ent = symtab.get('j')
        self.assertFalse(j_ent is None)
        j_rec = j_ent.type
        self.assertTrue(len(j_rec.labels) == 1)
        self.assertTrue('x' in j_rec.labels)