Пример #1
0
 def assertSuccess(self, input_lines):
     errors = Errors()
     output = Render(input_lines, self.machine, indent=False,
                     errors=errors).run()
     self.assertEquals(errors.num_errors, 0)
     self.assertEquals(errors.num_warnings, 0)
     return output
Пример #2
0
 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)
Пример #3
0
    def assertSuccess(self, input):
        errors = Errors()
        Flatten(input, errors=errors).run()
        self.assertEquals(errors.num_errors, 0)
        self.assertEquals(errors.num_warnings, 0)

        Inline(input, errors=errors).run()
        self.assertEquals(errors.num_errors, 0)
        self.assertEquals(errors.num_warnings, 0)
Пример #4
0
    def __init__(self, **kwargs):
        if 'name' in kwargs:
            self.name = kwargs['name']
        else:
            self.name = self.__class__.__name__

        if 'errors' in kwargs:
            self.errors = kwargs['errors']
        else:
            self.errors = Errors()
Пример #5
0
 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)
Пример #6
0
 def add(self, name, decl, errors=Errors()):
     if name in self.symbols:
         prev_decl = self.symbols[name]
         errors.error(decl.get_location(), """'%s' conflicts with previous declaration at '%s'""" % (name, prev_decl.get_location()))
         return
     
     if self.parent is not None:
         prev_decl = self.parent.lookup(name)
         if prev_decl is not None:
             errors.warn(decl.get_location(), """'%s' shadows previous declaration at '%s'""" % (name, prev_decl.get_location()))
     
     self.symbols[name] = decl
Пример #7
0
 def assertSuccess(self, input):
     errors = Errors()
     lines = Linearise(input, errors=errors).run()
     self.assertEquals(errors.num_errors, 0)
     self.assertEquals(errors.num_warnings, 0)
     return lines
Пример #8
0
 def assertSuccess(self, input, expected_errors=0, expected_warnings=0):
     errors = Errors()
     Flatten(input, errors=errors).run()
     self.assertEquals(errors.num_errors, expected_errors)
     self.assertEquals(errors.num_warnings, expected_warnings)
Пример #9
0
 def assertFailure(self, input):
     errors = Errors()
     fl = Flatten(input, errors)
     self.assertEquals(errors.num_errors, 0)
     self.assertEquals(errors.num_warnings, 0)
Пример #10
0
 def __init__(self, filename, options):
     self.errors = Errors(filename)
     self.options = options
Пример #11
0
 def assertSuccess(self, input, expected_errors=0, expected_warnings=0):
     errors = Errors()
     VarCheck(input, self.builtins, errors=errors).run()
     self.assertEquals(errors.num_errors, expected_errors)
     self.assertEquals(errors.num_warnings, expected_warnings)
Пример #12
0
 def assertSuccess(self, input):
     errors = Errors()
     Reduce(input, errors=errors).run()
     self.assertEquals(errors.num_errors, 0)
     self.assertEquals(errors.num_warnings, 0)