| 1 | package de.uka.ipd.sdq.pcmsolver.tests; |
| 2 | |
| 3 | |
| 4 | public class LoopActionHandlerTest { |
| 5 | |
| 6 | // private LoopActionHandler loopActionHandler = null; |
| 7 | // private LoopAction loopAction = null; |
| 8 | // |
| 9 | // @Before |
| 10 | // public void setUp(){ |
| 11 | // Context context = new Context(); |
| 12 | // |
| 13 | // UsageFactory uf = UsageFactory.eINSTANCE; |
| 14 | // context.setUsageContext(uf.createUsageContext()); |
| 15 | // context.setCurrentLoopIterationNumber(new ArrayList()); |
| 16 | // |
| 17 | // SeffVisitor visitor = new SeffVisitor(null, context); |
| 18 | // |
| 19 | // loopActionHandler = new LoopActionHandler(context,visitor,null); |
| 20 | // |
| 21 | // SeffFactory sf = SeffFactory.eINSTANCE; |
| 22 | // loopAction = sf.createLoopAction(); |
| 23 | // |
| 24 | // IterationCount iterCount = sf.createIterationCount(); |
| 25 | // iterCount.setSpecification("5"); |
| 26 | // loopAction.setIterations_LoopAction(iterCount); |
| 27 | // |
| 28 | // } |
| 29 | // |
| 30 | // /** |
| 31 | // * Tests, whether the loop action handler correctly stores the given |
| 32 | // * specification for the number of loop iterations in the usage context. |
| 33 | // */ |
| 34 | // @Test |
| 35 | // public void handle(){ |
| 36 | // loopActionHandler.handle(loopAction); |
| 37 | // |
| 38 | // EList loopIterations = loopActionHandler.getMyContext().getUsageContext().getLoopiterations_UsageContext(); |
| 39 | // |
| 40 | // // loop iterations in usage context should not be empty |
| 41 | // assertFalse(loopIterations.isEmpty()); |
| 42 | // |
| 43 | // // loop iterations in usage context should contain "5" as first element |
| 44 | // assertTrue(((LoopIteration) loopIterations.get(0)).getSpecification() |
| 45 | // .equals("5")); |
| 46 | // |
| 47 | // // memorized loop iteration numbers should have been removed from the context |
| 48 | // assertTrue(loopActionHandler.getMyContext() |
| 49 | // .getCurrentLoopIterationNumber().size() == 0); |
| 50 | // } |
| 51 | // |
| 52 | // /** |
| 53 | // * Test whether the upper bound of a loop can be found if |
| 54 | // * the number of loop iterations is specified as an expression. |
| 55 | // */ |
| 56 | // @Test |
| 57 | // public void getUpperBound(){ |
| 58 | // // Should get highest value of IntPMF as upperBound |
| 59 | // String pmf = "IntPMF(unit=\"unit\")[ (0.1; 1) (0.2; 2) (0.7; 3) ]"; |
| 60 | // Expression expr = ExpressionHelper.parseToExpression(pmf); |
| 61 | // int upperBound = loopActionHandler.getUpperBound(expr); |
| 62 | // assertTrue(upperBound == 3); |
| 63 | // |
| 64 | // // Should get the constant as upperBound |
| 65 | // pmf = "5"; |
| 66 | // expr = ExpressionHelper.parseToExpression(pmf); |
| 67 | // upperBound = loopActionHandler.getUpperBound(expr); |
| 68 | // assertTrue(upperBound == 5); |
| 69 | // |
| 70 | // // DoublePMF do not work, because the loop cannot be executed 3.1 times |
| 71 | // pmf = "DoublePMF(unit=\"unit\")[ (0.1; 1.1) (0.2; 2.1) (0.7; 3.1) ]"; |
| 72 | // expr = ExpressionHelper.parseToExpression(pmf); |
| 73 | // upperBound = loopActionHandler.getUpperBound(expr); |
| 74 | // assertTrue(upperBound == 0); |
| 75 | // |
| 76 | // // DoublePDF do not work either |
| 77 | // pmf = "DoublePDF(unit=\"unit\")[ (0.1; 1.1) (0.2; 2.1) (0.7; 3.1) ]"; |
| 78 | // expr = ExpressionHelper.parseToExpression(pmf); |
| 79 | // upperBound = loopActionHandler.getUpperBound(expr); |
| 80 | // assertTrue(upperBound == 0); |
| 81 | // } |
| 82 | // |
| 83 | // public static junit.framework.Test suite() { |
| 84 | // return new JUnit4TestAdapter(LoopActionHandlerTest.class); |
| 85 | // } |
| 86 | |
| 87 | } |