Oops, yes, there is a bug in my code:
FIXED_SIZE can't be reused for multiple instances of TestCollection, so it must 
not be static.
Correction:

public class TestCollection<E> extends AbstractCollection<E> {

    private final E[] elements;
    private final int[] fixedSize;
    private int[] sizes;
    private int nextSize;

    public TestCollection(E[] elements) {
        this.elements = elements;
        setSizeSequence(fixedSize = new int[]{elements.length});
    }

    void setSizeSequence(int... sizes) {
        this.sizes = sizes != null ? sizes : fixedSize;
        nextSize = 0;
    }

   ...

-Ulf


Am 30.03.2012 09:45, schrieb Sean Chou:
Hi Ulf,

    While try the ToArray.java testcase, I got the following output with 
jdk1.7.0_01:

java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1342)
        at InfraStructure.fail(InfraStructure.java:9)
        at InfraStructure.check(InfraStructure.java:12)
        at ToArray.test(ToArray.java:39)
        at InfraStructure.run(InfraStructure.java:20)
        at ToArray.main(ToArray.java:114)
java.lang.ArrayIndexOutOfBoundsException: 2
        at ToArray.test(ToArray.java:40)
        at InfraStructure.run(InfraStructure.java:20)
        at ToArray.main(ToArray.java:114)


The ArrayIndexOutOfBoundsException is easy to figure out, will you please have a look at the first one?


On Thu, Mar 29, 2012 at 2:48 AM, Ulf Zibis <ulf.zi...@gmx.de 
<mailto:ulf.zi...@gmx.de>> wrote:

    Hi David, Sean,

    I have made little changes to make understanding little easier, see 
attachment...

    -Ulf



    Am 28.03.2012 07:29, schrieb David Holmes:

        Hi Ulf,


        I understand your point about ensuring we test 
AbstractCollection.toArray but I find this
        revised test much harder to understand.

        Also in the name setPseudoConcurrentSizeCourse the word "Course" 
doesn't fit. I'm not sure
        what you were meaning here? Perhaps just modifySize or 
emulateConcurrentSizeChange ?

        Thanks,
        David




--
Best Regards,
Sean Chou

Reply via email to