review31: Providing randomized Arithmetica test to verify inconsistencies with version 1.0
1.1 --- a/samples/composition/src-test/api/ArithmeticaCompatibilityTest.java Sat Jun 14 10:01:18 2008 +0200
1.2 +++ b/samples/composition/src-test/api/ArithmeticaCompatibilityTest.java Sat Jun 14 10:01:21 2008 +0200
1.3 @@ -56,6 +56,7 @@
1.4 }
1.5 } // end of CountingSubclass
1.6
1.7 + // BEGIN: total.rewrite.tests
1.8 public void testRandomCheck () throws Exception {
1.9 long seed = System.currentTimeMillis();
1.10 try {
1.11 @@ -99,8 +100,10 @@
1.12 assertEquals("Verify amount of sumAll is the same", now.countSumAll, old.countSumAll);
1.13 assertEquals("Verify amount of sumTwo is the same", now.countSumTwo, old.countSumTwo);
1.14 }
1.15 + // END: total.rewrite.tests
1.16
1.17 - private void compare (CountingSubclass now, CountingOldSubclass old, long seed) throws Exception {
1.18 + // BEGIN: total.rewrite.compare
1.19 + private void compare (Arithmetica now, OldArithmetica1 old, long seed) throws Exception {
1.20 java.util.Random r = new java.util.Random (seed);
1.21
1.22 for (int loop = 0; loop < r.nextInt(5); loop++) {
1.23 @@ -135,9 +138,10 @@
1.24 }
1.25 }
1.26 }
1.27 + // END: total.rewrite.compare
1.28
1.29
1.30 -
1.31 + // BEGIN: total.rewrite.oldimpl
1.32 /** This is a copy of the implementation of Arithmetica from version 1.0 */
1.33 static class OldArithmetica1 {
1.34 public int sumTwo(int one, int second) {
1.35 @@ -163,6 +167,7 @@
1.36 }
1.37 return sumAll(array);
1.38 }
1.39 - } // end of OldArithmetica1
1.40 + }
1.41 + // END: total.rewrite.oldimpl
1.42
1.43 }