-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from ftsrg/cfachecks
Check CFA variables and locations for unique names
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
subprojects/cfa/cfa/src/test/java/hu/bme/mit/theta/cfa/CfaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package hu.bme.mit.theta.cfa; | ||
|
||
import hu.bme.mit.theta.core.decl.Decls; | ||
import hu.bme.mit.theta.core.decl.VarDecl; | ||
import hu.bme.mit.theta.core.stmt.Stmts; | ||
import hu.bme.mit.theta.core.type.inttype.IntExprs; | ||
import hu.bme.mit.theta.core.type.inttype.IntType; | ||
import org.junit.Test; | ||
|
||
public class CfaTest { | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testDuplicateLocationName() { | ||
CFA.Builder builder = CFA.builder(); | ||
builder.createLoc("A"); | ||
builder.createLoc("B"); | ||
builder.createLoc("A"); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testDuplicateVarName() { | ||
CFA.Builder builder = CFA.builder(); | ||
VarDecl<IntType> v1 = Decls.Var("x", IntExprs.Int()); | ||
VarDecl<IntType> v2 = Decls.Var("x", IntExprs.Int()); | ||
CFA.Loc init = builder.createLoc(); | ||
CFA.Loc loc1 = builder.createLoc(); | ||
CFA.Loc loc2 = builder.createLoc(); | ||
builder.createEdge(init, loc1, Stmts.Havoc(v1)); | ||
builder.createEdge(init, loc2, Stmts.Havoc(v2)); | ||
builder.setInitLoc(init); | ||
builder.build(); | ||
} | ||
} |