static data is not reinitialized

One of these tests will fail:

    private static Complex w = new Complex(1, 1);
    
    public void testAddNumberToItselfStatic() {
        
        w = w.add(w);
        assertEquals(2.0, w.getRealPart(), 0.000001);
        assertEquals(2.0, w.getImaginaryPart(), 0.000001);
        
    }
    
    
    public void testAddNumberToItselfTwiceStatic() {
        
        w = w.add(w).add(w);
        assertEquals(3.0, w.getRealPart(), 0.000001);
        assertEquals(3.0, w.getImaginaryPart(), 0.000001);
        
    }

Previous | Next | Top | Cafe au Lait

Copyright 2005 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified May 19, 2005