コード例 #1
0
 def test_make_node(self):
     l1 = 1
     l2 = 2
     l3 = 3
     l4 = 4
     b = symbols.BOUND(l1, l2)
     c = symbols.BOUND(l3, l4)
     symbols.BOUNDLIST.make_node(None, b, c)
コード例 #2
0
 def setUp(self):
     self.clearOutput()
     self.s = gl_.SYMBOL_TABLE = SymbolTable()
     l1, l2, l3, l4 = 1, 2, 3, 4
     b = symbols.BOUND(l1, l2)
     c = symbols.BOUND(l3, l4)
     self.bounds = symbols.BOUNDLIST.make_node(None, b, c)
     self.func = symbols.FUNCDECL.make_node('testfunction', 1)
コード例 #3
0
 def setUp(self):
     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)
コード例 #4
0
 def test__len__(self):
     l1 = 1
     l2 = 2
     l3 = 3
     l4 = 4
     b = symbols.BOUND(l1, l2)
     c = symbols.BOUND(l3, l4)
     a = symbols.BOUNDLIST(b, c)
     self.assertEqual(len(a), 2)
コード例 #5
0
 def test__str__(self):
     l1 = 1
     l2 = 2
     l3 = 3
     l4 = 4
     b = symbols.BOUND(l1, l2)
     c = symbols.BOUND(l3, l4)
     a = symbols.BOUNDLIST.make_node(None, b, c)
     self.assertEqual(str(a),
                      '(({} TO {}), ({} TO {}))'.format(l1, l2, l3, l4))
コード例 #6
0
 def test_declare_local_array(self):
     """ the logic for declaring a local array differs from
     local scalar variables
     """
     self.s.enter_scope('testfunction')
     self.s.declare_array('a', 12, self.btyperef(TYPE.float_),
                          symbols.BOUNDLIST(symbols.BOUND(0, 2)))
     self.assertTrue(self.s.check_is_declared('a', 11, scope=self.s.current_scope))
     self.assertEqual(self.s.get_entry('a').scope, SCOPE.local)
コード例 #7
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')
コード例 #8
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')
コード例 #9
0
 def test__repr__(self):
     b = symbols.BOUND(1, 3)
     self.assertEqual(b.__repr__(), b.token + '(1 TO 3)')
コード例 #10
0
 def test__str__(self):
     b = symbols.BOUND(1, 3)
     self.assertEqual(str(b), '(1 TO 3)')
コード例 #11
0
 def test_count(self):
     lower = 1
     upper = 3
     b = symbols.BOUND(lower, upper)
     self.assertEqual(b.count, upper - lower + 1)