diff options
author | Geoff Berry <gcb@gnu.org> | 1998-07-07 00:10:44 +0000 |
---|---|---|
committer | Geoff Berry <gcb@gnu.org> | 1998-07-07 00:10:44 +0000 |
commit | a8cd3a399e839f9b8f9997a2d03fbcf49da9cbf5 (patch) | |
tree | 0261a5656b58d7ec81ccabb9f37d7ac07d7f8c5b /test | |
parent | a7781427a8cf0a592d06b7c057d805cf91b8a68b (diff) | |
download | classpath-a8cd3a399e839f9b8f9997a2d03fbcf49da9cbf5.tar.gz |
Added comments for gnu/java/lang/reflect/TypeSignature.java
java/io/ObjectStreamClass.java java/io/ObjectStreamConstants.java
native/java.io/java_io_ObjectStreamClass.c
Added initialization of int d2 in mergeSort(Object[],Comparator) to
placate javac.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/gnu.java.lang.reflect/Makefile.am | 5 | ||||
-rw-r--r-- | test/gnu.java.lang.reflect/TypeSignatureTest.java | 165 |
3 files changed, 171 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index da0ff4afd..bd3972a9a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ ## Input file for automake to generate the Makefile.in used by configure -SUBDIRS = java.net java.io +SUBDIRS = java.net java.io java.util gnu.java.lang.reflect diff --git a/test/gnu.java.lang.reflect/Makefile.am b/test/gnu.java.lang.reflect/Makefile.am new file mode 100644 index 000000000..fa9872470 --- /dev/null +++ b/test/gnu.java.lang.reflect/Makefile.am @@ -0,0 +1,5 @@ +## Input file for automake to generate the Makefile.in used by configure + +JAVAROOT = . + +check_JAVA = TypeSignatureTest.java diff --git a/test/gnu.java.lang.reflect/TypeSignatureTest.java b/test/gnu.java.lang.reflect/TypeSignatureTest.java new file mode 100644 index 000000000..02a12c760 --- /dev/null +++ b/test/gnu.java.lang.reflect/TypeSignatureTest.java @@ -0,0 +1,165 @@ +/************************************************************************* +/* TypeSignatureTest.java -- Tests TypeSignature class +/* +/* Copyright (c) 1998 by Geoffrey C. Berry (gcb@cs.duke.edu) +/* +/* This program is free software; you can redistribute it and/or modify +/* it under the terms of the GNU General Public License as published +/* by the Free Software Foundation, version 2. (see COPYING) +/* +/* This program is distributed in the hope that it will be useful, but +/* WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU General Public License for more details. +/* +/* You should have received a copy of the GNU General Public License +/* along with this program; if not, write to the Free Software Foundation +/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA +/*************************************************************************/ + + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Member; + +import gnu.java.lang.reflect.TypeSignature; + +public class TypeSignatureTest +{ + public static void pass() + { + System.out.print( "PASSED: " ); + } + + public static void fail() + { + System.out.print( "FAILED: " ); + } + + public static void testClass( Class clazz, String type_code ) + { + if( TypeSignature.getEncodingOfClass( clazz ).equals( type_code ) ) + pass(); + else + fail(); + + System.out.println( "class encoding of " + clazz ); + } + + public static void testConstructor( Constructor c, String type_code ) + { + if( TypeSignature.getEncodingOfConstructor( c ).equals( type_code ) ) + pass(); + else + fail(); + + System.out.println( "constructor encoding of " + c ); + } + + public static void testMethod( Method m, String type_code ) + { + if( TypeSignature.getEncodingOfMethod( m ).equals( type_code ) ) + pass(); + else + fail(); + + System.out.println( "method encoding of " + m ); + } + + public static void testMember( Member m, String type_code ) + { + if( TypeSignature.getEncodingOfMember( m ).equals( type_code ) ) + pass(); + else + fail(); + + System.out.println( "member encoding of " + m ); + } + + public static void main( String[] args ) + { + try + { + // test getEncodingOfClass + testClass( Boolean.TYPE, "Z" ); + testClass( Byte.TYPE, "B" ); + testClass( Character.TYPE, "C" ); + testClass( Double.TYPE, "D" ); + testClass( Float.TYPE, "F" ); + testClass( Integer.TYPE, "I" ); + testClass( Long.TYPE, "J" ); + testClass( Short.TYPE, "S" ); + testClass( (new int[] {}).getClass(), "[I" ); + testClass( (new float[][][] {}).getClass(), "[[[F" ); + testClass( String.class, "Ljava/lang/String;" ); + testClass( TypeSignatureTest.class, "LTypeSignatureTest;" ); + + // test named inner-class + TypeSignatureTest tst = new TypeSignatureTest(); + Inner i = tst.new Inner(); + testClass( i.getClass(), + "LTypeSignatureTest$Inner;" ); + + // test anonymous inner-class + testClass( + (new Anon() { public void f() {} }).getClass(), + "LTypeSignatureTest$1;" ); + + //test getEncodingOfConstructor + testConstructor( String.class.getConstructor( new Class[] {} ), + "()V" ); + testConstructor( + String.class.getConstructor( new Class[] + { (new byte[]{}).getClass() } ), + "([B)V" ); + + testConstructor( + String.class.getConstructor( new Class[] { StringBuffer.class } ), + "(Ljava/lang/StringBuffer;)V" ); + + // test getEncodingOfMethod + testMethod( + String.class.getMethod( "lastIndexOf", + new Class[] { Integer.TYPE, Integer.TYPE } ), + "(II)I" ); + + testMethod( + String.class.getMethod( "length", new Class[] {} ), + "()I" ); + + testMethod( + TypeSignatureTest.class.getMethod( "pass", new Class[] {} ), + "()V" ); + + testMember( + TypeSignatureTest.class.getField( "i" ), + "I" ); + + testMember( + TypeSignatureTest.class.getField( "s" ), + "Ljava/lang/String;" ); + + testMember( + TypeSignatureTest.class.getField( "o" ), + "[[Ljava/lang/Object;" ); + } + catch( Exception e ) + { + e.printStackTrace(); + } + } + + public int i; + public String s; + public Object[][] o; + + + class Inner + {} +} + + +interface Anon +{ + public void f(); +} |