def testOneItemInParent(self): parent = SymbolTable() st = SymbolTable(parent) parent.add('x', self.x, None) self.assertEquals(st.get_names(), set()) self.assertEquals(st.get_all_names(), set(['x'])) self.assertEquals(st.lookup('x'), self.x)
def testConflict(self): st = SymbolTable() errors = Errors() st.add('x', self.x, errors) st.add('x', self.x2, errors) self.assertEquals(errors.num_errors, 1) self.assertEquals(st.get_names(), set(['x'])) self.assertEquals(st.lookup('x'), self.x)
def testShadow(self): parent = SymbolTable() parent.add('x', self.x, None) st = SymbolTable(parent) errors = Errors() st.add('x', self.x2, errors) self.assertEquals(errors.num_warnings, 1) self.assertEquals(st.get_names(), set(['x'])) self.assertEquals(st.get_all_names(), set(['x'])) self.assertEquals(st.lookup('x'), self.x2)