comparison visualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java @ 4512:015fb895586b

Moved visualizer to new directory.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 07 Feb 2012 22:41:09 +0100
parents
children
comparison
equal deleted inserted replaced
4511:6cb549627941 4512:015fb895586b
1 /*
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package com.sun.hotspot.igv.data;
26
27 import static org.hamcrest.CoreMatchers.is;
28 import static org.hamcrest.CoreMatchers.nullValue;
29 import static org.junit.Assert.assertThat;
30 import org.junit.*;
31
32 /**
33 *
34 * @author Thomas
35 */
36 public class InputMethodTest {
37
38 public InputMethodTest() {
39 }
40
41 @BeforeClass
42 public static void setUpClass() throws Exception {
43 }
44
45 @AfterClass
46 public static void tearDownClass() throws Exception {
47 }
48
49 @Before
50 public void setUp() {
51 }
52
53 @After
54 public void tearDown() {
55 }
56
57
58 /**
59 * Test of getBytecodes method, of class InputMethod.
60 */
61 @Test
62 public void testGetSetBytecodes() {
63
64 final String input = "0 iload_0\n" +
65 "1 iconst_1\n" +
66 "2 if_icmpne 7\n" +
67 "5 iconst_1\n" +
68 "6 ireturn\n" +
69 "7 iconst_0\n" +
70 "8 ireturn";
71
72 final Group g = new Group(null);
73 InputMethod m = new InputMethod(g, "name", "shortName", -1);
74 m.setBytecodes(input);
75
76 assertThat(m.getBytecodes().size(), is(7));
77
78 assertThat(m.getBytecodes().get(0).getBci(), is(0));
79 assertThat(m.getBytecodes().get(1).getBci(), is(1));
80 assertThat(m.getBytecodes().get(2).getBci(), is(2));
81 assertThat(m.getBytecodes().get(3).getBci(), is(5));
82
83 assertThat(m.getBytecodes().get(0).getName(), is("iload_0"));
84 assertThat(m.getBytecodes().get(1).getName(), is("iconst_1"));
85 assertThat(m.getBytecodes().get(2).getName(), is("if_icmpne 7"));
86 assertThat(m.getBytecodes().get(6).getName(), is("ireturn"));
87
88 assertThat(m.getBytecodes().get(2).getInlined(), nullValue());
89 assertThat(m.getBytecodes().get(6).getInlined(), nullValue());
90 }
91
92
93 }