From: Steve F. <sm...@us...> - 2002-09-29 16:44:32
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test In directory usw-pr-cvs1:/tmp/cvs-serv20790/src/core/com/mockobjects/test Modified Files: TestVerifier.java Log Message: Some tidy-up Initial refactorings towards avoiding static collection Hid verifyField() Index: TestVerifier.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test/TestVerifier.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TestVerifier.java 17 Sep 2002 14:51:11 -0000 1.2 +++ TestVerifier.java 29 Sep 2002 16:44:28 -0000 1.3 @@ -12,7 +12,7 @@ class OneVerifiable extends MockObject { private ExpectationValue myValue = new ExpectationValue("should fail"); - private int anotherField; + private int unusedField; public OneVerifiable() { myValue.setFailOnVerify(); @@ -27,6 +27,25 @@ class InheritVerifiable extends OneVerifiable { } + class LoopingVerifiable extends MockObject { + LoopingVerifiable myRef = this; + boolean inVerify = false; + + LoopingVerifiable() { + super(); + } + + public void setRef(LoopingVerifiable aRef) { + myRef = aRef; + } + + public void verify() { + assertTrue("Looping verification detected", !inVerify); + inVerify = true; + super.verify(); + inVerify = false; + } + } public TestVerifier(String name) { super(name); @@ -94,39 +113,16 @@ oneVerifiable.verify(); } - - class LoopingVerifiable extends MockObject { - LoopingVerifiable myRef; - boolean inVerify = false; - - LoopingVerifiable(LoopingVerifiable aRef) { - setRef(aRef); - } - - - public void setRef(LoopingVerifiable aRef) { - myRef = (aRef == null) ? this : aRef; - } - - public void verify() { - assertTrue("Looping verification detected", !inVerify); - inVerify = true; - super.verify(); - inVerify = false; - } - } - public void testNoLoopVerifySingleLevel() { - new LoopingVerifiable(null).verify(); + new LoopingVerifiable().verify(); } - public void testNoLoopVerifyMultiLevel() { - LoopingVerifiable a = new LoopingVerifiable(null); - LoopingVerifiable b = new LoopingVerifiable(a); + LoopingVerifiable a = new LoopingVerifiable(); + LoopingVerifiable b = new LoopingVerifiable(); a.setRef(b); + b.setRef(a); a.verify(); } - } |