1 /* Copyright (C) 2010 Red Hat, Inc. |
|
2 |
|
3 This file is part of Mauve. |
|
4 |
|
5 Mauve is free software; you can redistribute it and/or modify |
|
6 it under the terms of the GNU General Public License as published by |
|
7 the Free Software Foundation; either version 2, or (at your option) |
|
8 any later version. |
|
9 |
|
10 Mauve is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 GNU General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU General Public License |
|
16 along with Mauve; see the file COPYING. If not, write to |
|
17 the Free Software Foundation, 59 Temple Place - Suite 330, |
|
18 Boston, MA 02111-1307, USA. |
|
19 */ |
|
20 |
|
21 // Tags: JDK1.5 |
|
22 |
|
23 package gnu.testlet.java.lang.Class; |
|
24 |
|
25 import gnu.testlet.Testlet; |
|
26 import gnu.testlet.TestHarness; |
|
27 |
|
28 import java.lang.reflect.Array; |
|
29 |
|
30 public class IsAnonymousClass implements Testlet |
|
31 { |
|
32 public void test(TestHarness harness) |
|
33 { |
|
34 Class<?> anon = (new Object() { |
|
35 public String toString() { return "Hello!"; } |
|
36 }).getClass(); |
|
37 Class<?> anonArray = Array.newInstance(anon, 1).getClass(); |
|
38 |
|
39 harness.check(int.class.isAnonymousClass(), false, |
|
40 "Primitive type class"); |
|
41 harness.check(int[].class.isAnonymousClass(), false, |
|
42 "Primitive type one-dimensional array class"); |
|
43 harness.check(int[][].class.isAnonymousClass(), false, |
|
44 "Primitive type multi-dimensional array class"); |
|
45 harness.check(Object[].class.isAnonymousClass(), false, |
|
46 "Object type one-dimensional array class"); |
|
47 harness.check(Object.class.isAnonymousClass(), false, |
|
48 "Object type class"); |
|
49 harness.check(InnerClass.class.isAnonymousClass(), false, |
|
50 "Inner class"); |
|
51 harness.check(anon.isAnonymousClass(), true, "Anonymous class"); |
|
52 harness.check(anonArray.isAnonymousClass(), false, "Anonymous array class"); |
|
53 } |
|
54 |
|
55 public static class InnerClass { }; |
|
56 |
|
57 } |
|
58 |
|