PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/test/kilim/test/TestFlow.java

http://github.com/kilim/kilim
Java | 53 lines | 37 code | 6 blank | 10 comment | 5 complexity | bfd1667bd853528a5561c2148c8f27d5 MD5 | raw file
 1/* Copyright (c) 2006, Sriram Srinivasan
 2 *
 3 * You may distribute this software under the terms of the license 
 4 * specified in the file "License"
 5 */
 6
 7package kilim.test;
 8
 9import static kilim.Constants.D_BYTE;
10import kilim.analysis.BasicBlock;
11import kilim.analysis.Frame;
12import kilim.analysis.IncompatibleTypesException;
13import kilim.analysis.MethodFlow;
14import kilim.analysis.TypeDesc;
15import kilim.analysis.Value;
16import static kilim.test.TestTypeDesc.mergeType;
17
18public class TestFlow extends Base {
19
20    @Override
21    protected void setUp() throws Exception {
22        cache("kilim.test.ex.ExFlow");
23    }
24
25    public void testMerge() throws IncompatibleTypesException {
26        MethodFlow flow = getFlow("loop");
27        if (flow == null)
28            return;
29        // Make sure the merging is fine. There used to be a bug
30        assertEquals("Lkilim/test/ex/ExA;", mergeType("Lkilim/test/ex/ExC;", "Lkilim/test/ex/ExD;"));
31        assertEquals("Lkilim/test/ex/ExA;", mergeType("Lkilim/test/ex/ExD;", "Lkilim/test/ex/ExC;"));
32        BasicBlock bb = getBBForMethod(flow, "join");
33        assertTrue(bb != null);
34        Frame f = bb.startFrame;
35        // Check Locals
36        // assertEquals("Lkilim/test/ex/ExFlow;", f.getLocal(0));
37        assertEquals("Lkilim/test/ex/ExA;", f.getLocal(1).getTypeDesc());
38        // assertSame(D_INT, f.getLocal(2));
39        // Check operand stack
40        assertSame(D_BYTE, f.getStack(0).getTypeDesc());
41        assertEquals("Lkilim/test/ex/ExFlow;", f.getStack(1).getTypeDesc());
42        assertEquals("Lkilim/test/ex/ExA;", f.getStack(2).getTypeDesc());
43    }
44
45    public void testConstants() throws IncompatibleTypesException {
46        MethodFlow flow = getFlow("loop");
47        if (flow == null)
48            return;
49        BasicBlock bb = getBBForMethod(flow, "join");
50        Frame f = bb.startFrame;
51        assertSame(f.getLocal(2).getConstVal(), Value.NO_VAL);
52    }
53}