Ejemplo n.º 1
0
            return out
        exprs = self.ira.blocs[node.label].irs[node.line_nb]
        exprs_str = '\\l'.join([str(x) for x in exprs])
        return "%s %s" % (out, exprs_str)


# Test structures
print "[+] Test structures"

print "[+] Test DependencyDict"
dd0 = DependencyDict(lbl0, [])
depnodes_0 = [DependencyNode(lbl0, a, i) for i in xrange(10)][::-1]

## Heads
assert (list(dd0.heads()) == [])
assert (dd0.is_head(depnodes_0[-1]) == True)
assert (dd0.is_head(depnodes_0[0]) == False)
dd0.cache[depnodes_0[-1]] = set(depnodes_0[-1:])
assert (list(dd0.heads()) == [depnodes_0[-1]])

## Extend
dd1 = dd0.extend(lbl1)

assert (dd1.label == lbl1)
assert (dd1.history == [dd0])
assert (dd1.cache == dd0.cache)
assert (dd1.pending == set())
assert (dd1 != dd0)

dd1.cache[depnodes_0[4]] = set(depnodes_0[5:9])
assert (dd1.cache != dd0.cache)
Ejemplo n.º 2
0
            return out
        exprs = self.ira.blocs[node.label].irs[node.line_nb]
        exprs_str = '\\l'.join([str(x) for x in exprs])
        return "%s %s" % (out, exprs_str)

# Test structures
print "[+] Test structures"

print "[+] Test DependencyDict"
DD0 = DependencyDict(LBL0, [])
DEPNODES_0 = [DependencyNode(LBL0, A, linenb, next(STEP_COUNTER))
              for linenb in xrange(10)][::-1]

# Heads
assert list(DD0.heads()) == []
assert DD0.is_head(DEPNODES_0[-1]) == True
assert DD0.is_head(DEPNODES_0[0]) == False
DD0.cache[DEPNODES_0[-1]] = set(DEPNODES_0[-1:])
assert list(DD0.heads()) == [DEPNODES_0[-1]]

# Extend
DD1 = DD0.extend(LBL1)

assert DD1.label == LBL1
assert DD1.history == [DD0]
assert DD1.cache == DD0.cache
assert DD1.pending == set()
assert DD1 != DD0

DD1.cache[DEPNODES_0[4]] = set(DEPNODES_0[5:9])
assert DD1.cache != DD0.cache
Ejemplo n.º 3
0
        if not (0 <= node.line_nb < len(self.ira.blocs[node.label].irs)):
            return out
        exprs = self.ira.blocs[node.label].irs[node.line_nb]
        exprs_str = '\\l'.join([str(x) for x in exprs])
        return "%s %s"%(out, exprs_str)

# Test structures
print "[+] Test structures"

print "[+] Test DependencyDict"
dd0 = DependencyDict(lbl0, [])
depnodes_0 = [DependencyNode(lbl0, a, i) for i in xrange(10)][::-1]

## Heads
assert(list(dd0.heads()) == [])
assert(dd0.is_head(depnodes_0[-1]) == True)
assert(dd0.is_head(depnodes_0[0]) == False)
dd0.cache[depnodes_0[-1]] = set(depnodes_0[-1:])
assert(list(dd0.heads()) == [depnodes_0[-1]])

## Extend
dd1 = dd0.extend(lbl1)

assert(dd1.label == lbl1)
assert(dd1.history == [dd0])
assert(dd1.cache == dd0.cache)
assert(dd1.pending == set())
assert(dd1 != dd0)

dd1.cache[depnodes_0[4]] = set(depnodes_0[5:9])
assert(dd1.cache != dd0.cache)
Ejemplo n.º 4
0
        return "%s %s" % (out, exprs_str)


# Test structures
print "[+] Test structures"

print "[+] Test DependencyDict"
DD0 = DependencyDict(LBL0, [])
DEPNODES_0 = [
    DependencyNode(LBL0, A, linenb, next(STEP_COUNTER))
    for linenb in xrange(10)
][::-1]

# Heads
assert list(DD0.heads()) == []
assert DD0.is_head(DEPNODES_0[-1]) == True
assert DD0.is_head(DEPNODES_0[0]) == False
DD0.cache[DEPNODES_0[-1]] = set(DEPNODES_0[-1:])
assert list(DD0.heads()) == [DEPNODES_0[-1]]

# Extend
DD1 = DD0.extend(LBL1)

assert DD1.label == LBL1
assert DD1.history == [DD0]
assert DD1.cache == DD0.cache
assert DD1.pending == set()
assert DD1 != DD0

DD1.cache[DEPNODES_0[4]] = set(DEPNODES_0[5:9])
assert DD1.cache != DD0.cache