Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
stschott committed Nov 5, 2024
1 parent ed382eb commit 98e4e7b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* #L%
*/

import java.util.Iterator;
import java.util.List;
import sootup.core.graph.BasicBlock;
import sootup.core.jimple.common.constant.Constant;
import sootup.core.jimple.common.constant.IntConstant;
Expand All @@ -30,9 +32,6 @@
import sootup.core.jimple.common.stmt.*;
import sootup.core.jimple.javabytecode.stmt.*;

import java.util.Iterator;
import java.util.List;

/**
* This class contains the equivalence implementations for the individual {@link
* EquivTo#equivTo(Object)} methods of the Jimple IR. You can use it as your base class if your use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

@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));
}
@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));
}
}

0 comments on commit 98e4e7b

Please sign in to comment.