Mercurial > lcfOS
comparison python/testgraph.py @ 278:9fca39eebe50
First implementation of regalloc with coalsesc
author | Windel Bouwman |
---|---|
date | Sun, 29 Sep 2013 14:08:15 +0200 |
parents | 046017431c6a |
children | 2ccd57b1d78c |
comparison
equal
deleted
inserted
replaced
277:046017431c6a | 278:9fca39eebe50 |
---|---|
3 import unittest | 3 import unittest |
4 import graph | 4 import graph |
5 | 5 |
6 class GraphTestCase(unittest.TestCase): | 6 class GraphTestCase(unittest.TestCase): |
7 def testEdge(self): | 7 def testEdge(self): |
8 g = graph.Graph(False) | 8 g = graph.Graph() |
9 n1 = g.newNode() | 9 n1 = graph.Node(g) |
10 n2 = g.newNode() | 10 g.addNode(n1) |
11 n2 = graph.Node(g) | |
12 g.addNode(n2) | |
11 g.addEdge(n1, n2) | 13 g.addEdge(n1, n2) |
12 self.assertTrue(g.hasEdge(n2, n1)) | 14 self.assertTrue(g.hasEdge(n2, n1)) |
13 self.assertTrue(g.hasEdge(n1, n2)) | 15 self.assertTrue(g.hasEdge(n1, n2)) |
14 g.delNode(n1) | 16 g.delNode(n1) |
15 g.delNode(n2) | 17 g.delNode(n2) |
16 | 18 |
17 def testDegree(self): | 19 def testDegree(self): |
18 g = graph.Graph(False) | 20 g = graph.Graph() |
19 n1 = g.newNode() | 21 n1 = graph.Node(g) |
20 n2 = g.newNode() | 22 g.addNode(n1) |
21 n3 = g.newNode() | 23 n2 = graph.Node(g) |
24 g.addNode(n2) | |
25 n3 = graph.Node(g) | |
26 g.addNode(n3) | |
22 g.addEdge(n1, n2) | 27 g.addEdge(n1, n2) |
23 g.addEdge(n1, n3) | 28 g.addEdge(n1, n3) |
24 self.assertEqual(2, n1.Degree) | 29 self.assertEqual(2, n1.Degree) |
25 self.assertEqual(1, n2.Degree) | 30 self.assertEqual(1, n2.Degree) |
26 g.delNode(n2) | 31 g.delNode(n2) |