File tree Expand file tree Collapse file tree 5 files changed +35
-15
lines changed
main/scala/br/unb/cic/soot
test/scala/br/unb/cic/soot Expand file tree Collapse file tree 5 files changed +35
-15
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ class Graph[NodeT]() {
1616 val map = new mutable.HashMap [NodeT ,mutable.MutableList [NodeT ]]()
1717
1818 def addEdge (source : NodeT , target : NodeT ): Unit = {
19+ if (source == target) {
20+ return
21+ }
22+
1923 if (map.contains(source)) {
2024 val adjacentList = map.get(source).get
2125 adjacentList += target
Original file line number Diff line number Diff line change @@ -69,8 +69,8 @@ abstract class SVFA {
6969
7070 for (n <- svg.nodes()) {
7171 nodeColor = n.nodeType match {
72- case SourceNode => " [blue]"
73- case SinkNode => " [red]"
72+ case SourceNode => " [fillcolor= blue, style=filled ]"
73+ case SinkNode => " [fillcolor= red, style=filled ]"
7474 case _ => " "
7575 }
7676
Original file line number Diff line number Diff line change 11package br .unb .cic .soot
22
33import br .unb .cic .soot .graph ._
4- import org .scalatest .FunSuite
4+ import org .scalatest .{ BeforeAndAfter , FunSuite }
55import scalax .collection .Graph
66import scalax .collection .GraphEdge .DiEdge
77import soot .jimple .{AssignStmt , InvokeExpr , InvokeStmt }
@@ -33,14 +33,22 @@ class BlackBoard extends JSVFATest {
3333 }
3434}
3535
36- class BlackBoardTestSuite extends FunSuite {
36+ class BlackBoardTestSuite extends FunSuite with BeforeAndAfter {
3737
38- test(" we should correctly compute the number of nodes and edges" ) {
39- val svfa = new BlackBoard ()
38+ val svfa = new BlackBoard ()
39+
40+ before {
4041 svfa.buildSparseValueFlowGraph()
41- println(svfa.reportConflicts())
42+ }
43+
44+ test(" we should correctly compute the number of nodes and edges" ) {
4245 assert(svfa.svg.nodes.size == 7 )
43- assert(svfa.svg.numberOfEdges() == 7 )
46+ assert(svfa.svg.numberOfEdges() == 6 )
47+ }
48+
49+ test(" we should find exactly one conflict in this analysis" ) {
50+ println(svfa.svgToDotModel())
51+ assert(svfa.reportConflicts().size == 0 )
4452 }
4553
4654}
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class CC16TestSuite extends FunSuite with BeforeAndAfter {
3939
4040 test(" we should correctly compute the number of nodes and edges" ) {
4141 assert(svfa.svg.nodes.size == 10 )
42- assert(svfa.svg.numberOfEdges() == 10 )
42+ assert(svfa.svg.numberOfEdges() == 9 )
4343 }
4444
4545 test(" we should find exactly one conflict in this analysis" ) {
Original file line number Diff line number Diff line change 11package br .unb .cic .soot
22
33import br .unb .cic .soot .graph ._
4- import org .scalatest .FunSuite
4+ import org .scalatest .{ BeforeAndAfter , FunSuite }
55import soot .jimple .{AssignStmt , InvokeExpr , InvokeStmt }
66
77class IfElseTest extends JSVFATest {
@@ -33,13 +33,21 @@ class IfElseTest extends JSVFATest {
3333}
3434
3535
36- class IfElseTestSuite extends FunSuite {
37- test(" we should correctly compute the number of nodes and edges" ) {
38- val svfa = new IfElseTest ()
36+ class IfElseTestSuite extends FunSuite with BeforeAndAfter {
37+ var svfa : IfElseTest = _
38+
39+ before {
40+ svfa = new IfElseTest ()
3941 svfa.buildSparseValueFlowGraph()
42+ }
43+
44+ test(" we should correctly compute the number of nodes and edges" ) {
4045 assert(svfa.svg.nodes.size == 12 )
41- assert(svfa.svg.numberOfEdges() == 13 )
46+ assert(svfa.svg.numberOfEdges() == 11 )
47+ }
4248
43- assert(! svfa.reportConflicts().isEmpty)
49+ test(" we should find exactly one conflict in this analysis" ) {
50+ println(svfa.svgToDotModel())
51+ assert(svfa.reportConflicts().size == 1 )
4452 }
4553}
You can’t perform that action at this time.
0 commit comments