|
| 1 | +package soot.jimple.spark.solver; |
| 2 | + |
| 3 | +/*- |
| 4 | + * #%L |
| 5 | + * Soot - a J*va Optimization Framework |
| 6 | + * %% |
| 7 | + * Copyright (C) 1997 - 2018 Raja Vallée-Rai and others |
| 8 | + * %% |
| 9 | + * This program is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Lesser General Public License as |
| 11 | + * published by the Free Software Foundation, either version 2.1 of the |
| 12 | + * License, or (at your option) any later version. |
| 13 | + * |
| 14 | + * This program is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Lesser Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Lesser Public |
| 20 | + * License along with this program. If not, see |
| 21 | + * <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 22 | + * #L% |
| 23 | + */ |
| 24 | + |
| 25 | +import java.util.Collections; |
| 26 | + |
| 27 | +import org.junit.Test; |
| 28 | + |
| 29 | +import static org.junit.Assert.assertEquals; |
| 30 | + |
| 31 | +import soot.Scene; |
| 32 | +import soot.Type; |
| 33 | +import soot.jimple.spark.pag.PAG; |
| 34 | +import soot.jimple.spark.pag.VarNode; |
| 35 | +import soot.options.SparkOptions; |
| 36 | + |
| 37 | +public class SCCCollapserTest { |
| 38 | + |
| 39 | + @Test |
| 40 | + public void testSeparateComponents() { |
| 41 | + Scene.v().loadBasicClasses(); |
| 42 | + Type type = Scene.v().getObjectType(); |
| 43 | + |
| 44 | + SparkOptions sparkOptions = new SparkOptions(Collections.emptyMap()); |
| 45 | + PAG pag = new PAG(sparkOptions); |
| 46 | + |
| 47 | + VarNode a = pag.makeGlobalVarNode("a", type); |
| 48 | + VarNode b = pag.makeGlobalVarNode("b", type); |
| 49 | + VarNode c = pag.makeGlobalVarNode("c", type); |
| 50 | + pag.addEdge(a, b); |
| 51 | + pag.addEdge(a, c); |
| 52 | + pag.addEdge(b, c); |
| 53 | + |
| 54 | + SCCCollapser sccCollapser = new SCCCollapser(pag, false); |
| 55 | + sccCollapser.collapse(); |
| 56 | + pag.cleanUpMerges(); |
| 57 | + |
| 58 | + assertEquals(a, a.getReplacement()); |
| 59 | + assertEquals(b, b.getReplacement()); |
| 60 | + assertEquals(c, c.getReplacement()); |
| 61 | + } |
| 62 | +} |
0 commit comments