Esempio n. 1
0
 def test_symbol_rewrite(self):
     symtab = rsl.symtab.SymbolTable()
     
     symtab.enter_scope()
     
     symtab.install_symbol('TEST', 'TEST1')
     symtab.install_symbol('TEST', 'TEST2')
     
     value = symtab.find_symbol("TEST")
     symtab.leave_scope()
     
     self.assertEqual(value, 'TEST2')
Esempio n. 2
0
 def test_symbol_store(self):
     symtab = rsl.symtab.SymbolTable()
     handle = "TEST"
     
     symtab.enter_scope()
     symtab.enter_scope()
     
     symtab.install_symbol('Test', handle)
     value = symtab.find_symbol("Test")
     symtab.leave_scope()
     
     self.assertRaises(rsl.symtab.SymtabException, symtab.find_symbol, "Test")
     
     self.assertEqual(handle, value)
Esempio n. 3
0
    def test_get_scope_symbols(self):
        symtab = rsl.symtab.SymbolTable()
        
        symtab.enter_scope()
        self.assertEqual(len(symtab.scope_head.symbols), 0)
        
        symtab.install_symbol('TEST', 'TEST1')
        symtab.install_symbol('TEST', 'TEST2')
        self.assertEqual(len(symtab.scope_head.symbols), 1)
        
        symtab.install_symbol('TEST1', '')
        self.assertEqual(len(symtab.scope_head.symbols), 2)

        symtab.leave_scope()
        
        symtab.enter_scope()
        self.assertEqual(len(symtab.scope_head.symbols), 0)