PageRenderTime 15ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/test/kilim/test/TestJSR.java

http://github.com/kilim/kilim
Java | 42 lines | 29 code | 6 blank | 7 comment | 1 complexity | 1380d80f7c1cc34cee0c8e02abb51372 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 java.util.ArrayList;
10
11import kilim.analysis.BasicBlock;
12import kilim.analysis.MethodFlow;
13
14public class TestJSR extends Base {
15    public void testJSRSizes() throws Exception {
16        String className = "kilim.test.ex.ExJSR";
17        try {
18            Class.forName(className);
19        } catch (ClassNotFoundException cnfe) {
20            fail("Please use jasmin to compile " + className);
21        } catch (VerifyError e) {
22            fail("Verification error for " + className + ": " + e.getMessage());
23        }
24        cache(className);
25        MethodFlow flow = getFlow("simpleJSR");
26        assertEquals(3, flow.getBasicBlocks().size());
27        flow = getFlow("pausableJSR1");
28//        System.out.println(flow.getBasicBlocks());
29        assertEquals(5, flow.getBasicBlocks().size());
30
31        flow = getFlow("pausableJSR2");
32        ArrayList<BasicBlock> bbs = flow.getBasicBlocks();
33        assertEquals(9, bbs.size());
34        
35        // make sure the blocks are unique
36        int flag = 1 << 12;
37        for (BasicBlock bb: bbs) {
38            assertFalse("BasicBlock list contains duplicates", bb.hasFlag(flag));
39            bb.setFlag(flag);
40        }
41    }
42}