Esempio n. 1
0
    def test_auto(self):
        st = SymbolTable()
        st.auto('x')
        st.auto('y')

        self.assertEquals(st.fetch('x'), Symbol('x', 'auto', -1))
        self.assertEquals(st.fetch('y'), Symbol('y', 'auto', -2))
        self.assertEquals(st.auto_count, 2)
Esempio n. 2
0
    def test_redeclaration(self):
        st = SymbolTable()
        st.auto('x')

        with self.assertRaises(Redeclaration):
            st.auto('x')
        with self.assertRaises(Redeclaration):
            st.arg('x')
        with self.assertRaises(Redeclaration):
            st.label('x', 7)
        with self.assertRaises(Redeclaration):
            st.extrn('x')
Esempio n. 3
0
    def test_label_redeclaration(self):
        st = SymbolTable()
        st.auto('x')
        st.extrn('y')
        st.arg('z')

        # Cannot use a variable as a label and then declare it as a different
        # type.
        with self.assertRaises(Redeclaration):
            st.label('x', 7)
        with self.assertRaises(Redeclaration):
            st.label('y', 8)
        with self.assertRaises(Redeclaration):
            st.label('z', 9)