Skip to content

Commit b2eb816

Browse files
committed
Move test only method to test
1 parent 3b4d375 commit b2eb816

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

key.core/src/main/java/de/uka/ilkd/key/java/Services.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,6 @@ public Counter getCounter(String name) {
317317
return c;
318318
}
319319

320-
/**
321-
* Reset all counters associated with this service.
322-
* Only use this method if the proof is empty!
323-
*/
324-
public void resetCounters() {
325-
if (proof.root().childrenCount() > 0) {
326-
throw new IllegalStateException("tried to reset counters on non-empty proof");
327-
}
328-
counters.clear();
329-
}
330-
331320
/**
332321
* returns the namespaces for functions, predicates etc.
333322
*

key.core/src/test/java/de/uka/ilkd/key/proof/replay/TestCopyingReplayer.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
* SPDX-License-Identifier: GPL-2.0-only */
44
package de.uka.ilkd.key.proof.replay;
55

6+
import java.lang.reflect.Field;
67
import java.nio.file.Files;
78
import java.nio.file.Path;
9+
import java.util.HashMap;
810
import java.util.HashSet;
911

1012
import de.uka.ilkd.key.control.KeYEnvironment;
13+
import de.uka.ilkd.key.proof.Counter;
1114
import de.uka.ilkd.key.proof.Proof;
1215
import de.uka.ilkd.key.settings.GeneralSettings;
1316

@@ -27,6 +30,25 @@
2730
class TestCopyingReplayer {
2831
public static final Path testCaseDirectory = FindResources.getTestCasesDirectory();
2932

33+
/**
34+
* Reset all counters associated with this service.
35+
* Only use this method if the proof is empty!
36+
*/
37+
public void resetCounters(Proof proof) {
38+
if (proof.root().childrenCount() > 0) {
39+
throw new IllegalStateException("tried to reset counters on non-empty proof");
40+
}
41+
42+
try {
43+
final Field countersField = proof.getServices().getClass().getDeclaredField("counters");
44+
countersField.setAccessible(true);
45+
// noinspection unchecked
46+
((HashMap<String, Counter>) countersField.get(proof.getServices())).clear();
47+
} catch (NoSuchFieldException | IllegalAccessException e) {
48+
throw new RuntimeException(e);
49+
}
50+
}
51+
3052
@Test
3153
void testJavaProof() throws Exception {
3254
GeneralSettings.noPruningClosed = false;
@@ -48,7 +70,7 @@ void testJavaProof() throws Exception {
4870

4971
// clear proof2, replay proof1 on top
5072
proof2.pruneProof(proof2.root());
51-
proof2.getServices().resetCounters();
73+
resetCounters(proof2);
5274
new CopyingProofReplayer(proof1, proof2).copy(proof1.root(),
5375
proof2.getOpenGoal(proof2.root()), new HashSet<>());
5476

0 commit comments

Comments
 (0)