-
-
Notifications
You must be signed in to change notification settings - Fork 81
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 #1126 from soot-oss/fix/switchComparison
Fix switch comparison
- Loading branch information
Showing
4 changed files
with
54 additions
and
19 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
42 changes: 42 additions & 0 deletions
42
sootup.core/src/test/java/sootup/core/jimple/basic/JimpleComparatorTest.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,42 @@ | ||
package sootup.core.jimple.basic; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import sootup.core.jimple.Jimple; | ||
import sootup.core.jimple.common.constant.IntConstant; | ||
import sootup.core.jimple.javabytecode.stmt.JSwitchStmt; | ||
import sootup.core.types.PrimitiveType; | ||
|
||
@Tag("Java8") | ||
public class JimpleComparatorTest { | ||
|
||
@Test | ||
public void test() { | ||
// l1 and l2 are equal, l1 and l3 are not | ||
Local l1 = Jimple.newLocal("l", PrimitiveType.getInt()); | ||
Local l2 = Jimple.newLocal("l", PrimitiveType.getInt()); | ||
Local l3 = Jimple.newLocal("l", PrimitiveType.getBoolean()); | ||
|
||
List<IntConstant> lookup1 = new ArrayList<>(); | ||
lookup1.add(IntConstant.getInstance(3)); | ||
lookup1.add(IntConstant.getInstance(5)); | ||
lookup1.add(IntConstant.getInstance(999)); | ||
|
||
List<IntConstant> lookup2 = new ArrayList<>(); | ||
lookup2.add(IntConstant.getInstance(3)); | ||
lookup2.add(IntConstant.getInstance(5)); | ||
lookup2.add(IntConstant.getInstance(999)); | ||
|
||
JSwitchStmt switch1 = Jimple.newLookupSwitchStmt(l1, lookup1, StmtPositionInfo.NOPOSITION); | ||
JSwitchStmt switch2 = Jimple.newLookupSwitchStmt(l2, lookup2, StmtPositionInfo.NOPOSITION); | ||
JSwitchStmt switch3 = Jimple.newLookupSwitchStmt(l3, lookup2, StmtPositionInfo.NOPOSITION); | ||
|
||
assertTrue(switch1.equivTo(switch2)); | ||
assertFalse(switch1.equivTo(switch3)); | ||
} | ||
} |
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