1 package serp.bytecode;
2
3 import junit.framework.*;
4 import junit.textui.*;
5
6
7
8
9
10
11 public class TestArray extends AbstractStateTest {
12 private BCClass _bc2 = null;
13
14 public TestArray(String test) {
15 super(test);
16 }
17
18 public void setUp() {
19 _bc = _project.loadClass(String[].class);
20 _bc2 = _project.loadClass(int[][].class);
21 }
22
23 public void testType() {
24 assertEquals(String[].class.getName(), _bc.getName());
25 assertEquals("java.lang", _bc.getPackageName());
26 assertEquals("String[]", _bc.getClassName());
27 assertEquals(String[].class, _bc.getType());
28
29 try {
30 _bc.setName("Foo[]");
31 fail("Allowed set name");
32 } catch (UnsupportedOperationException uoe) {
33 }
34
35 assertTrue(!_bc.isPrimitive());
36 assertTrue(_bc.isArray());
37
38 assertEquals(int[][].class.getName(), _bc2.getName());
39 assertNull(_bc2.getPackageName());
40 assertEquals("int[][]", _bc2.getClassName());
41 assertEquals(int[][].class, _bc2.getType());
42 }
43
44 public void testSuperclass() {
45 assertEquals(Object.class.getName(), _bc.getSuperclassName());
46 try {
47 _bc.setSuperclass("Foo");
48 fail("Allowed set superclass");
49 } catch (UnsupportedOperationException uoe) {
50 }
51 }
52
53 public void testComponent() {
54 assertEquals(String.class.getName(), _bc.getComponentName());
55 assertEquals(String.class, _bc.getComponentType());
56 assertEquals(String.class, _bc.getComponentBC().getType());
57 assertEquals(int[].class.getName(), _bc2.getComponentName());
58 assertEquals(int[].class, _bc2.getComponentType());
59 assertEquals(int[].class, _bc2.getComponentBC().getType());
60 }
61
62 public static Test suite() {
63 return new TestSuite(TestArray.class);
64 }
65
66 public static void main(String[] args) {
67 TestRunner.run(suite());
68 }
69 }