You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Neil O'Toole <ne...@yahoo.com> on 2003/04/26 05:50:11 UTC
[collections] [patch] ArrayIterator#hasNext bug
bug in ArrayIterator#hasNext. Currently:
public boolean hasNext() {
return (index <= endIndex);
}
should be:
public boolean hasNext() {
return (index <= endIndex);
}
I don't currently have the configuration on this machine to run the
test suite, so I'd appreciate it if the commmitter could run the suite
in case this messes anything else up (and maybe add a test case for
this??).
- Neil
Re: [collections] [patch] ArrayIterator#hasNext bug
Posted by Neil O'Toole <ne...@yahoo.com>.
Sorry, should have mentioned the problem. The iterator wasn't returning
the last element of the array. I can fish out some test code to
demonstrate this if you need.
Neil
--- Stephen Colebourne <sc...@btopenworld.com> wrote:
> I have checked the code and the test suite and all looks fine to me.
> Can you
> provide any more info?
>
> Stephen
>
> ----- Original Message -----
> From: "Neil O'Toole" <ne...@yahoo.com>
> To: <co...@jakarta.apache.org>
> Sent: Saturday, April 26, 2003 4:50 AM
> Subject: [collections] [patch] ArrayIterator#hasNext bug
>
>
> > bug in ArrayIterator#hasNext. Currently:
> >
> > public boolean hasNext() {
> > return (index <= endIndex);
> > }
> >
> > should be:
> >
> > public boolean hasNext() {
> > return (index <= endIndex);
> > }
> >
> > I don't currently have the configuration on this machine to run the
> > test suite, so I'd appreciate it if the commmitter could run the
> suite
> > in case this messes anything else up (and maybe add a test case for
> > this??).
> >
> > - Neil
> >
> >
> >
>
>
>
----------------------------------------------------------------------------
> ----
>
>
> > Index: ArrayIterator.java
> > ===================================================================
> > RCS file:
>
x:/apps/cvsnt/cvs_repository/main/commons-collections-20030425/src/java/org/
> apache/commons/collections/iterators/ArrayIterator.java,v
> > retrieving revision 1.1
> > diff -u -r1.1 ArrayIterator.java
> > --- ArrayIterator.java 26 Apr 2003 03:37:40 -0000 1.1
> > +++ ArrayIterator.java 26 Apr 2003 03:42:22 -0000
> > @@ -176,7 +176,7 @@
> > * @return true if there is a next element to return
> > */
> > public boolean hasNext() {
> > - return (index < endIndex);
> > + return (index <= endIndex);
> > }
> >
> > /**
> >
> >
>
>
>
----------------------------------------------------------------------------
> ----
>
>
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [collections] [patch] ArrayIterator#hasNext bug
Posted by Stephen Colebourne <sc...@btopenworld.com>.
I have checked the code and the test suite and all looks fine to me. Can you
provide any more info?
Stephen
----- Original Message -----
From: "Neil O'Toole" <ne...@yahoo.com>
To: <co...@jakarta.apache.org>
Sent: Saturday, April 26, 2003 4:50 AM
Subject: [collections] [patch] ArrayIterator#hasNext bug
> bug in ArrayIterator#hasNext. Currently:
>
> public boolean hasNext() {
> return (index <= endIndex);
> }
>
> should be:
>
> public boolean hasNext() {
> return (index <= endIndex);
> }
>
> I don't currently have the configuration on this machine to run the
> test suite, so I'd appreciate it if the commmitter could run the suite
> in case this messes anything else up (and maybe add a test case for
> this??).
>
> - Neil
>
>
>
----------------------------------------------------------------------------
----
> Index: ArrayIterator.java
> ===================================================================
> RCS file:
x:/apps/cvsnt/cvs_repository/main/commons-collections-20030425/src/java/org/
apache/commons/collections/iterators/ArrayIterator.java,v
> retrieving revision 1.1
> diff -u -r1.1 ArrayIterator.java
> --- ArrayIterator.java 26 Apr 2003 03:37:40 -0000 1.1
> +++ ArrayIterator.java 26 Apr 2003 03:42:22 -0000
> @@ -176,7 +176,7 @@
> * @return true if there is a next element to return
> */
> public boolean hasNext() {
> - return (index < endIndex);
> + return (index <= endIndex);
> }
>
> /**
>
>
----------------------------------------------------------------------------
----
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [collections] [patch] ArrayIterator#hasNext bug
Posted by Neil O'Toole <ne...@yahoo.com>.
Whoops. Staring at the screen farrrrr too long. Thanks Henri.
--- Henri Yandell <ba...@generationjava.com> wrote:
>
> Currently it's index < endIndex
>
> I imagine Neil meant this.
>
> Hen
>
> On Fri, 25 Apr 2003, Neil O'Toole wrote:
>
> > bug in ArrayIterator#hasNext. Currently:
> >
> > public boolean hasNext() {
> > return (index <= endIndex);
> > }
> >
> > should be:
> >
> > public boolean hasNext() {
> > return (index <= endIndex);
> > }
> >
> > I don't currently have the configuration on this machine to run the
> > test suite, so I'd appreciate it if the commmitter could run the
> suite
> > in case this messes anything else up (and maybe add a test case for
> > this??).
> >
> > - Neil
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [collections] [patch] TestList and TestCollection
Posted by Stephen Colebourne <sc...@btopenworld.com>.
Applied, thanks
Stephen
----- Original Message -----
From: "Neil O'Toole" <ne...@yahoo.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Saturday, April 26, 2003 7:13 AM
Subject: [collections] [patch] TestList and TestCollection
> And of course, here come the actual patch files a little later...
>
> - Neil
>
> >>>>>>>>>>>
> A small bug from the glamourous side of open-source (down in the bowels
> of the test suite). TestList#BulkTestSubList was missing the
> isSetSupported() operation. This is added in the patch, as well as a
> few minor changes to the test output in TestList.java and
> TestCollection.java to make testing a bit easier, e.g.
>
> assertTrue("Empty collection shouldn'y contain element",
> !collection.contains(elements[i]));
>
> becomes
>
> assertTrue("Empty collection shouldn't contain element[" + i + "]",
> !collection.contains(elements[i]));
>
> As a general note when writing test code, there is really no gain from
> writing succinct statements or trying to save on assignments, and it
> does make life harder for people using the test suites. So, instead of
> writing:
>
> assertTrue( myObject.getSomething().equals( somethingElse ))
>
> we're better off doing
>
> Something s = myObject.getSomething();
> assertTrue( s.equals( somethingElse ));
>
> As that sort of code generally makes it much easier to debug (even with
> all these new-fangled fancy debuggers).
>
> - Neil
>
----------------------------------------------------------------------------
----
> Index: TestCollection.java
> ===================================================================
> RCS file:
x:/apps/cvsnt/cvs_repository/main/commons-collections-20030425/src/test/org/
apache/commons/collections/TestCollection.java,v
> retrieving revision 1.1
> diff -u -r1.1 TestCollection.java
> --- TestCollection.java 26 Apr 2003 03:37:33 -0000 1.1
> +++ TestCollection.java 26 Apr 2003 05:58:17 -0000
> @@ -579,7 +579,7 @@
> resetEmpty();
> elements = getFullElements();
> for(int i = 0; i < elements.length; i++) {
> - assertTrue("Empty collection shouldn'y contain element",
> + assertTrue("Empty collection shouldn't contain element[" + i
+ "]",
> !collection.contains(elements[i]));
> }
> // make sure calls to "contains" don't change anything
> @@ -587,7 +587,7 @@
>
> elements = getOtherElements();
> for(int i = 0; i < elements.length; i++) {
> - assertTrue("Empty collection shouldn'y contain element",
> + assertTrue("Empty collection shouldn't contain element[" + i
+ "]",
> !collection.contains(elements[i]));
> }
> // make sure calls to "contains" don't change anything
> @@ -596,7 +596,7 @@
> resetFull();
> elements = getFullElements();
> for(int i = 0; i < elements.length; i++) {
> - assertTrue("Full collection should contain element.",
> + assertTrue("Full collection should contain element[" + i +
"]",
> collection.contains(elements[i]));
> }
> // make sure calls to "contains" don't change anything
>
----------------------------------------------------------------------------
----
> Index: TestList.java
> ===================================================================
> RCS file:
x:/apps/cvsnt/cvs_repository/main/commons-collections-20030425/src/test/org/
apache/commons/collections/TestList.java,v
> retrieving revision 1.1
> diff -u -r1.1 TestList.java
> --- TestList.java 26 Apr 2003 03:37:34 -0000 1.1
> +++ TestList.java 26 Apr 2003 05:59:18 -0000
> @@ -804,10 +804,10 @@
> List list = getList();
>
> while (i > 0) {
> - assertTrue("Iterator should have next", iter.hasPrevious());
> - assertEquals("Iterator.nextIndex should work",
> + assertTrue("Iterator should have previous, i:" + i,
iter.hasPrevious());
> + assertEquals("Iterator.nextIndex should work, i:" + i,
> iter.nextIndex(), i);
> - assertEquals("Iterator.previousIndex should work",
> + assertEquals("Iterator.previousIndex should work, i:" + i,
> iter.previousIndex(), i - 1);
> Object o = iter.previous();
> assertEquals("Iterator returned correct element",
> @@ -816,8 +816,8 @@
> }
>
> assertTrue("Iterator shouldn't have previous",
!iter.hasPrevious());
> - assertEquals("nextIndex should be 0", iter.nextIndex(), 0);
> - assertEquals("previousIndex should be -1",
> + assertEquals("nextIndex should be 0, actual value: " +
iter.nextIndex(), iter.nextIndex(), 0);
> + assertEquals("previousIndex should be -1, actual value: " +
iter.previousIndex(),
> iter.previousIndex(), -1);
>
> try {
> @@ -1048,6 +1048,10 @@
> protected boolean isAddSupported() {
> return outer.isAddSupported();
> }
> +
> + protected boolean isSetSupported() {
> + return outer.isSetSupported();
> + }
>
>
> protected boolean isRemoveSupported() {
>
>
----------------------------------------------------------------------------
----
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[collections] [patch] TestList and TestCollection
Posted by Neil O'Toole <ne...@yahoo.com>.
And of course, here come the actual patch files a little later...
- Neil
>>>>>>>>>>>
A small bug from the glamourous side of open-source (down in the bowels
of the test suite). TestList#BulkTestSubList was missing the
isSetSupported() operation. This is added in the patch, as well as a
few minor changes to the test output in TestList.java and
TestCollection.java to make testing a bit easier, e.g.
assertTrue("Empty collection shouldn'y contain element",
!collection.contains(elements[i]));
becomes
assertTrue("Empty collection shouldn't contain element[" + i + "]",
!collection.contains(elements[i]));
As a general note when writing test code, there is really no gain from
writing succinct statements or trying to save on assignments, and it
does make life harder for people using the test suites. So, instead of
writing:
assertTrue( myObject.getSomething().equals( somethingElse ))
we're better off doing
Something s = myObject.getSomething();
assertTrue( s.equals( somethingElse ));
As that sort of code generally makes it much easier to debug (even with
all these new-fangled fancy debuggers).
- Neil
[collections] [patch] TestList and TestCollection
Posted by Neil O'Toole <ne...@users.sourceforge.net>.
A small bug from the glamourous side of open-source (down in the bowels
of the test suite). TestList#BulkTestSubList was missing the
isSetSupported() operation. This is added in the patch, as well as a
few minor changes to the test output in TestList.java and
TestCollection.java to make testing a bit easier, e.g.
assertTrue("Empty collection shouldn'y contain element",
!collection.contains(elements[i]));
becomes
assertTrue("Empty collection shouldn't contain element[" + i + "]",
!collection.contains(elements[i]));
As a general note when writing test code, there is really no gain from
writing succinct statements or trying to save on assignments, and it
does make life harder for people using the test suites. So, instead of
writing:
assertTrue( myObject.getSomething().equals( somethingElse ))
we're better off doing
Something s = myObject.getSomething();
assertTrue( s.equals( somethingElse ));
As that sort of code generally makes it much easier to debug (even with
all these new-fangled fancy debuggers).
- Neil
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [collections] [patch] ArrayIterator#hasNext bug
Posted by Henri Yandell <ba...@generationjava.com>.
Currently it's index < endIndex
I imagine Neil meant this.
Hen
On Fri, 25 Apr 2003, Neil O'Toole wrote:
> bug in ArrayIterator#hasNext. Currently:
>
> public boolean hasNext() {
> return (index <= endIndex);
> }
>
> should be:
>
> public boolean hasNext() {
> return (index <= endIndex);
> }
>
> I don't currently have the configuration on this machine to run the
> test suite, so I'd appreciate it if the commmitter could run the suite
> in case this messes anything else up (and maybe add a test case for
> this??).
>
> - Neil
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org