public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* Source Contribution
@ 2000-07-26  8:03 Gurevich, Naum
  2000-07-27 18:59 ` Tom Tromey
  2001-02-07 14:08 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Gurevich, Naum @ 2000-07-26  8:03 UTC (permalink / raw)
  To: 'mauve-discuss@sourceware.cygnus.com'

[-- Attachment #1: Type: text/plain, Size: 276 bytes --]

My name is Naum Gurevich. I am a Principal Software engineer with Net
Silicon. We are using Mauve test. In process we discover some missing tests
or what seems to be a bug. I will send my source code and comments in case
that somebody want to use them.

  <<ArrayTest.java>> 

[-- Attachment #2: ArrayTest.java --]
[-- Type: text/x-java, Size: 1744 bytes --]

/* Copyright (c) 1998 Free Software Foundation, Inc.
/* Written by  Naum Gurevich (ngurevich@netsilicon.com)

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.Array;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;

public class ArrayTest implements Testlet
{

   protected static TestHarness harness;
   
   private static final int ArrySize = 20;
   int [] intArry = new int[ArrySize];
   public void test (TestHarness the_harness)
   {
      harness = the_harness;
       harness.check((intArry.length == ArrySize), 
         "Array size "   );
      
      for (int i = 0;  i < ArrySize; i++)
         intArry[i] = i*5;
      for (int i = 0;  i < ArrySize; i++)
      {
         harness.check ( (intArry[i] == i*5),
            "Value at index " + i);
         try 
         {
            int result = intArry[ArrySize];
            harness.check(false," Out of Bouds failure");
         }
         catch ( ArrayIndexOutOfBoundsException err)
         {
            harness.check(true," Out of Bouds test");   
         } 
      }
   }

}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Source Contribution
  2000-07-26  8:03 Source Contribution Gurevich, Naum
@ 2000-07-27 18:59 ` Tom Tromey
  2000-07-28  2:06   ` Peter Naulls
  2001-02-07 14:08 ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2000-07-27 18:59 UTC (permalink / raw)
  To: Gurevich, Naum; +Cc: 'mauve-discuss@sourceware.cygnus.com'

>>>>> "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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Source Contribution
  2000-07-27 18:59 ` Tom Tromey
@ 2000-07-28  2:06   ` Peter Naulls
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Naulls @ 2000-07-28  2:06 UTC (permalink / raw)
  To: mauve-discuss

In message < 200007280159.SAA09754@ferrule.cygnus.com >
          Tom Tromey <tromey@cygnus.com> wrote:

> 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?

It might be nice to add them under a Virtual Machine section - I'm sure
there are plenty of other tests like this.

-- 
------------------------------------------------------------------------
 Peter Naulls - peter@erble.freeserve.co.uk
 Homepage - http://free.prohosting.com/~chocky/
 Java for RISC OS and ARM - http://free.prohosting.com/~chocky/java/
 Debian Linux on RiscPCs - http://www.erble.freeserve.co.uk/
------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Source Contribution
  2000-07-26  8:03 Source Contribution Gurevich, Naum
  2000-07-27 18:59 ` Tom Tromey
@ 2001-02-07 14:08 ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2001-02-07 14:08 UTC (permalink / raw)
  To: Gurevich, Naum; +Cc: 'mauve-discuss@sourceware.cygnus.com'

>>>>> "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.

Unbelievably, I've finally looked at this test.  It only took me,
what, 9 months?  (Though to be fair to me somebody else could have
done it too...)

I'm not going to check it in.  Right now Mauve really only checks
library issues, and this test is testing basic array manipulation.

We could make a new area to do these sorts of tests.  Someone would
have to push forward on this.  (Maybe someday I will.  But not today,
I'm afraid.)

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Source Contribution
  2000-07-28  5:38 Gurevich, Naum
@ 2000-07-28  9:17 ` Tom Tromey
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2000-07-28  9:17 UTC (permalink / raw)
  To: Gurevich, Naum
  Cc: 'Tom Tromey', 'mauve-discuss@sourceware.cygnus.com'

>>>>> "Naum" == Gurevich, Naum <NGurevich@NETsilicon.com> writes:

Naum> Anything is fine with me. One more problem with Mauve test
Naum> Section 10.7 of Java Language Specification explicitly specifies
Naum> that array implements 2 interfaces, not 1 as assumed in
Naum> java.lang.Class.ClassTest.

ClassTest is tagged "JLS1.0".  In 1.0 array only implemented a single
interface.  1.1 or 1.2 implementations probably shouldn't run this
test.  That is easy to set up using a tag file.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Source Contribution
@ 2000-07-28  5:38 Gurevich, Naum
  2000-07-28  9:17 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Gurevich, Naum @ 2000-07-28  5:38 UTC (permalink / raw)
  To: 'Tom Tromey', Gurevich, Naum
  Cc: 'mauve-discuss@sourceware.cygnus.com'

[-- 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 ();
  }

}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-02-07 14:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-26  8:03 Source Contribution Gurevich, Naum
2000-07-27 18:59 ` Tom Tromey
2000-07-28  2:06   ` Peter Naulls
2001-02-07 14:08 ` Tom Tromey
2000-07-28  5:38 Gurevich, Naum
2000-07-28  9:17 ` Tom Tromey

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).