From: "Gurevich, Naum" <NGurevich@NETsilicon.com>
To: 'Tom Tromey' <tromey@cygnus.com>,
"Gurevich, Naum" <NGurevich@NETsilicon.com>
Cc: "'mauve-discuss@sourceware.cygnus.com'"
<mauve-discuss@sourceware.cygnus.com>
Subject: RE: Source Contribution
Date: Fri, 28 Jul 2000 05:38:00 -0000 [thread overview]
Message-ID: <3FEE3089984DD211ABCC00A0C9D346D0016A2B6A@postoffice.netsilicon.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]
Anything is fine with me. One more problem with Mauve test Section 10.7 of
Java Language Specification explicitly specifies that array implements 2
interfaces, not 1 as assumed in java.lang.Class.ClassTest. The following is
a corrected code. I made an additional changes to test_getClassloader:
Provide fully qualified name for "gnu.testlet.java.lang.Class.ClassTest".
Because this class must be loaded variable ldr1 must be not null.
Naum
-----Original Message-----
From: Tom Tromey [ mailto:tromey@cygnus.com ]
Sent: Thursday, July 27, 2000 10:00 PM
To: Gurevich, Naum
Cc: 'mauve-discuss@sourceware.cygnus.com'
Subject: Re: Source Contribution
>>>>> "Naum" == Gurevich, Naum <NGurevich@NETsilicon.com> writes:
Naum> My name is Naum Gurevich. I am a Principal Software engineer
Naum> with Net Silicon. We are using Mauve test. In process we
Naum> discover some missing tests or what seems to be a bug. I will
Naum> send my source code and comments in case that somebody want to
Naum> use them.
Thanks.
This test looks like it tests general runtime stuff and not any
particular class. Right now we don't have a framework for doing that
in Mauve. I think we ought to add one. Mostly that just means
picking a new name for the test. Any suggestions?
Tom
[-- Attachment #2: ClassTest.java --]
[-- Type: text/x-java, Size: 10489 bytes --]
/* Copyright (C) 1999, 2000 Hewlett-Packard Company
This file is part of Mauve.
Mauve 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; either version 2, or (at your option)
any later version.
Mauve 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 Mauve; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// Tags: JLS1.0
package gnu.testlet.java.lang.Class;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.io.*;
import java.net.*;
public class ClassTest implements Cloneable, java.io.Serializable, Testlet
{
protected static TestHarness harness;
public void test_toString()
{
if ( !getClass().toString().equals(getClass().isInterface()?
"interface " : "class " +
getClass().getName()))
{
harness.fail("Error: toString returned wrong string");
}
if ( !(new Object()).getClass().toString().equals("class java.lang.Object"))
{
harness.fail("Error: toString returned wrong string");
}
}
public void test_getName()
{
try {
if ( ! (new java.util.Vector()).getClass().getName().equals("java.util.Vector"))
harness.fail("Error: getName returned wrong string - 1");
if ( ! (new Object[3]).getClass().getName().equals("[Ljava.lang.Object;"))
harness.fail("Error: getName returned wrong string - 2");
if ( ! ( new int[6][7][8]).getClass().getName().equals("[[[I"))
harness.fail("Error: getName returned wrong string - 3");
}catch ( Error e ){
harness.fail("Error: getName failed - 4");
}
}
public void test_isInterface()
{
if ( (new Object()).getClass().isInterface())
harness.fail("Error: isInterface returned wrong result - 1");
if ( getClass().isInterface())
harness.fail("Error: isInterface returned wrong result - 2");
try {
if ( !Class.forName("java.lang.Cloneable").isInterface())
harness.fail("Error: isInterface returned wrong result - 3");
}
catch ( Exception e ){}
}
public void test_getSuperclass()
{
try {
if( (new Boolean(true)).getClass().getSuperclass() !=
Class.forName("java.lang.Object"))
harness.fail("Error: getSuperclass returned wrong values - 1");
}catch ( Exception e ){}
if ( (new Object()).getClass().getSuperclass() != null )
harness.fail("Error: getSuperclass returned wrong values - 2");
try {
Class clss = Class.forName("[[I");
if ( clss.getSuperclass() != Class.forName(
"java.lang.Object"))
harness.fail(" Error : getSuperclass " +
" failed - 3 " );
}
catch ( Exception e ){
harness.fail(" Error: getSuperclass failed - 4");
}
try {
Class clss = Class.forName("[D");
if ( clss.getSuperclass() != Class.forName(
"java.lang.Object"))
harness.fail(" Error : getSuperclass " +
" failed - 5 " );
}
catch ( Exception e ){
harness.fail(" Error: getSuperclass failed - 6");
}
}
public void test_getInterfaces()
{
Class clss[] = getClass().getInterfaces();
Class clclass = null,clclass1 = null;
try {
clclass = Class.forName("java.lang.Cloneable");
clclass1 = Class.forName("java.io.Serializable");
}catch ( Exception e ){}
if ( clss == null )
harness.fail("Error: getInterfaces returned wrong values - 1");
else
if ( clss.length != 3 )
harness.fail("Error: getInterfaces returned wrong values - 2");
else
if (!( clss[0] == clclass && clss[1] == clclass1))
{
harness.fail("Error: getInterfaces returned wrong values - 3");
for (int i = 0; i < clss.length; i++)
{
harness.debug ("" + clss[i], false);
harness.debug (" ", false);
}
harness.debug ("");
}
try {
Class clsss = Class.forName("[[I");
harness.check ( clsss.getInterfaces().length, 2 );
}
catch ( Exception e ){
harness.fail(" Error: getInterfaces failed - 5");
}
try {
Class clsss = Class.forName("[D");
harness.check ( clsss.getInterfaces().length, 2 );
}
catch ( Exception e ){
harness.fail(" Error: getInterfaces failed - 7");
}
}
public void test_newInstance()
{
Class clss = getClass();
Object obj;
try {
obj = clss.newInstance();
obj = clss.newInstance();
obj = clss.newInstance();
obj = clss.newInstance();
}
catch ( Exception e ){
harness.fail("Error: newInstance failed ");
}
catch ( Error e ){
harness.fail("Error: newInstance failed " +
" with out of memory error " );
}
}
public void test_forName()
{
harness.checkPoint("forName");
try {
Object obj = Class.forName("java.lang.Object");
harness.check ( obj != null );
}
catch ( Exception e ){
harness.check(false);
}
try {
Object obj1 = Class.forName("ab.cd.ef");
harness.check(false);
}
catch ( ClassNotFoundException e ){
harness.check(true);
}
try {
// The docs say that this should fail.
Object obj2 = Class.forName("I");
harness.check(false);
}
catch ( ClassNotFoundException e ){
harness.check(true);
}
}
public void test_getClassloader()
{
ClassLoader ldr,ldr1;
try {
Class obj1 = Class.forName("java.lang.String");
ldr = obj1.getClassLoader();
if ( ldr != null )
harness.fail("Error: test_getClassLoader failed - 1");
Class obj2 = Class.forName("gnu.testlet.java.lang.Class.ClassTest");
ldr1 = obj2.getClassLoader();
if ( ldr1 == null )
harness.fail("Error: test_getClassLoader failed - 2");
}
catch ( Exception e ){
harness.fail("Error: test_getClassLoader failed - 2");
}
}
public void test_ComponentType()
{
try {
Class obj1 = Class.forName("java.lang.String");
if ( obj1.getComponentType() != null )
harness.fail("Error: test_getComponentType failed - 1");
Class obj2 = Class.forName("java.lang.Exception");
if ( obj2.getComponentType() != null )
harness.fail("Error: test_getComponentType failed - 2");
Class arrclass = Class.forName("[I");
if ( arrclass.getComponentType() == null )
harness.fail("Error: test_getComponentType failed - 3");
arrclass = Class.forName("[[[[I");
if ( arrclass.getComponentType() == null )
harness.fail("Error: test_getComponentType failed - 4");
}
catch ( Exception e ){
harness.fail("Error: test_getComponentType failed - 6");
}
}
public void test_isMethods()
{
try {
Class obj1 = Class.forName("java.lang.String");
if ( !obj1.isInstance("babu"))
harness.fail("Error: test_isMethods failed - 1");
Class obj2 = Class.forName("java.lang.Integer");
if ( !obj2.isInstance(new Integer(10)))
harness.fail("Error: test_isMethods failed - 2");
int arr[]= new int[3];
Class arrclass = Class.forName("[I");
if ( !arrclass.isInstance(arr))
harness.fail("Error: test_isMethods failed - 3");
Class cls1 = Class.forName("java.lang.String");
Class supercls = Class.forName("java.lang.Object");
if ( !supercls.isAssignableFrom( cls1 ))
harness.fail("Error: test_isMethods failed - 4");
if ( cls1.isAssignableFrom( supercls ))
harness.fail("Error: test_isMethods failed - 5");
Class cls2 = Class.forName("java.lang.String");
if ( !cls2.isAssignableFrom( cls1 ))
harness.fail("Error: test_isMethods failed - 6");
arrclass = Class.forName("[I");
Class arrclass1 = Class.forName("[[[I");
Class arrclass2 = Class.forName("[[D");
if ( arrclass.isArray() &&
arrclass1.isArray() &&
arrclass2.isArray() )
{}
else
harness.fail("Error : test_isMethods failed - 7" );
}
catch ( Exception e ){
harness.fail("Error: test_isMethods failed - 6");
}
}
public void test_getResource()
{
// this test assume the classpath setting include current directory
try {
FileInputStream is = new FileInputStream("ClassTest.class");
URL url = getClass().getResource("gnu.testlet.java.lang.Class.ClassTest.class");
if (url == null)
harness.fail("Error : test_getResource Failed - 1");
InputStream uis = url.openStream();
byte[] b1 = new byte[100];
byte[] b2 = new byte[100];
int ret = is.read(b1);
if (ret != 100)
harness.fail("Error : test_getResource Failed - 2");
ret = uis.read(b2);
if (ret != 100)
harness.fail("Error : test_getResource Failed - 3");
for (int i=0; i < 100; i++){
if (b1[i] != b2[i]){
harness.fail("Error : test_getResource Failed - 4");
break;
}
}
uis = getClass().getResourceAsStream("ClassTest.class");
if (uis == null)
harness.fail("Error : test_getResource Failed - 5");
ret = uis.read(b2);
if (ret != 100)
harness.fail("Error : test_getResource Failed - 6");
for (int i=0; i < 100; i++){
if (b1[i] != b2[i]){
harness.fail("Error : test_getResource Failed - 7");
break;
}
}
}catch (Throwable e){
harness.fail("Error : test_getResource Failed - 0");
}
}
public void testall()
{
test_toString();
test_getName();
test_isInterface();
test_getSuperclass();
test_getInterfaces();
test_newInstance();
test_forName();
test_ComponentType();
test_getClassloader();
test_isMethods();
test_getResource();
}
public void test (TestHarness the_harness)
{
harness = the_harness;
testall ();
}
}
next reply other threads:[~2000-07-28 5:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-28 5:38 Gurevich, Naum [this message]
2000-07-28 9:17 ` Tom Tromey
-- strict thread matches above, loose matches on Subject: below --
2000-07-26 8:03 Gurevich, Naum
2000-07-27 18:59 ` Tom Tromey
2000-07-28 2:06 ` Peter Naulls
2001-02-07 14:08 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3FEE3089984DD211ABCC00A0C9D346D0016A2B6A@postoffice.netsilicon.com \
--to=ngurevich@netsilicon.com \
--cc=mauve-discuss@sourceware.cygnus.com \
--cc=tromey@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).