Ejemplo n.º 1
0
    def setUp(self):
        zxbpp.init()
        l1 = 1
        l2 = 2
        l3 = 3
        l4 = 4
        b = symbols.BOUND(l1, l2)
        c = symbols.BOUND(l3, l4)
        self.bounds = symbols.BOUNDLIST.make_node(None, b, c)
        self.arr = symbols.VARARRAY('test', self.bounds, 1, type_=Type.ubyte)
        self.arg = symbols.ARGLIST(
            symbols.ARGUMENT(symbols.NUMBER(2, 1, type_=Type.uinteger), 1),
            symbols.ARGUMENT(symbols.NUMBER(3, 1, type_=Type.uinteger), 1))
        gl.SYMBOL_TABLE = SymbolTable()
        # Clears stderr and prepares for capturing it
        del config.OPTIONS.stderr
        config.OPTIONS.add_option('stderr', None, StringIO())
        config.OPTIONS.add_option_if_not_defined('explicit', None, False)

        self.aa1 = symbols.ARRAYACCESS(self.arr, self.arg, 2, 'fake-filename')
Ejemplo n.º 2
0
 def test_make_node_warn(self):
     gl.SYMBOL_TABLE.declare_array('test',
                                   1,
                                   symbols.TYPEREF(self.arr.type_, 1),
                                   bounds=self.bounds)
     self.arg[1] = symbols.ARGUMENT(symbols.NUMBER(9, 1), 1)
     self.aa2 = symbols.ARRAYACCESS.make_node('test',
                                              self.arg,
                                              lineno=2,
                                              filename='fake-filename')
     self.assertIsNotNone(self.aa2)
     self.assertEqual(
         self.OUTPUT,
         "(stdin):2: warning: Array 'test' subscript out of range\n")
Ejemplo n.º 3
0
 def test_make_node_fail(self):
     gl.SYMBOL_TABLE.declare_array('test',
                                   1,
                                   symbols.TYPEREF(self.arr.type_, 1),
                                   bounds=self.bounds)
     self.arg = symbols.ARGLIST(symbols.ARGUMENT(symbols.NUMBER(2, 1), 1))
     self.aa2 = symbols.ARRAYACCESS.make_node('test',
                                              self.arg,
                                              lineno=2,
                                              filename='fake-filename')
     self.assertIsNone(self.aa2)
     self.assertEqual(
         self.OUTPUT,
         "(stdin):2: error: Array 'test' has 2 dimensions, not 1\n")
Ejemplo n.º 4
0
    def setUp(self):
        zxbpp.init()
        l1 = 1
        l2 = 2
        l3 = 3
        l4 = 4
        b = symbols.BOUND(l1, l2)
        c = symbols.BOUND(l3, l4)
        self.bounds = symbols.BOUNDLIST.make_node(None, b, c)
        self.arr = symbols.VARARRAY('test', self.bounds, 1, type_=Type.ubyte)
        self.arg = symbols.ARGLIST(
            symbols.ARGUMENT(symbols.NUMBER(2, 1, type_=Type.uinteger), 1),
            symbols.ARGUMENT(symbols.NUMBER(3, 1, type_=Type.uinteger), 1))
        gl.SYMBOL_TABLE = SymbolTable()
        # Clears stderr and prepares for capturing it
        del config.OPTIONS.stderr
        config.OPTIONS(config.Action.ADD, name='stderr', default=StringIO())
        config.OPTIONS(config.Action.ADD_IF_NOT_DEFINED,
                       name='explicit',
                       type=bool,
                       default=False)

        self.aa1 = symbols.ARRAYACCESS(self.arr, self.arg, 2, 'fake-filename')