Skip to content

Commit 64f902c

Browse files
committed
fix TestProofScriptCommand.java
1 parent 61d3362 commit 64f902c

File tree

8 files changed

+96
-7
lines changed

8 files changed

+96
-7
lines changed

key.core/src/test/java/de/uka/ilkd/key/scripts/TestProofScriptCommand.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: GPL-2.0-only */
44
package de.uka.ilkd.key.scripts;
55

6-
import java.io.File;
76
import java.io.IOException;
87
import java.net.URISyntaxException;
98
import java.nio.file.Files;
@@ -36,24 +35,27 @@
3635
* see {@link MasterHandlerTest} from where I copied quite a bit.
3736
*/
3837
public class TestProofScriptCommand {
39-
public record TestInstance(String key, String script, @Nullable String exception,
38+
public record TestInstance(
39+
String name,
40+
String key, String script, @Nullable String exception,
4041
String[] goals, Integer selectedGoal) {
4142
}
4243

4344
public static List<Arguments> data() throws IOException, URISyntaxException {
44-
var folder = Paths.get("src/test/resources/de/uka/ilkd/key/macros/scripts");
45+
var folder = Paths.get("src/test/resources/de/uka/ilkd/key/scripts/cases")
46+
.toAbsolutePath();
4547
try (var walker = Files.walk(folder)) {
4648
List<Path> files =
4749
walker.filter(it -> it.getFileName().toString().endsWith(".yml")).toList();
4850
var objectMapper = new ObjectMapper(new YAMLFactory());
4951
objectMapper.findAndRegisterModules();
5052

51-
List<Arguments> args = new ArrayList(files.size());
53+
List<Arguments> args = new ArrayList<>(files.size());
5254
for (Path path : files) {
5355
try {
5456
TestInstance instance =
5557
objectMapper.readValue(path.toFile(), TestInstance.class);
56-
args.add(Arguments.of(path.toFile(), instance));
58+
args.add(Arguments.of(instance));
5759
} catch (Exception e) {
5860
System.out.println(path);
5961
e.printStackTrace();
@@ -66,8 +68,8 @@ public static List<Arguments> data() throws IOException, URISyntaxException {
6668

6769
@ParameterizedTest
6870
@MethodSource("data")
69-
void testProofScript(File file, TestInstance data) throws Exception {
70-
var name = file.getName().replace(".yml", "");
71+
void testProofScript(TestInstance data) throws Exception {
72+
var name = data.name();
7173
Path tmpKey = Files.createTempFile("proofscript_key_" + name, ".key");
7274
Files.writeString(tmpKey, data.key());
7375

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: andRight
2+
key: |
3+
\predicates { a; b; }
4+
\problem { a & b }
5+
script: |
6+
rule andRight;
7+
goals:
8+
- ==> b
9+
- ==> a
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: hide.exec
2+
key: |
3+
\predicates { a; b; c; d; e; f; }
4+
\problem { a -> b }
5+
6+
script: |
7+
macro "split-prop";
8+
hide "b ==>";
9+
10+
exception: |
11+
12+
Error while executing script: This formula is not on the sequent: b
13+
14+
Command: hide "b ==>";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: hide
2+
key: |
3+
\predicates { a; b; c; d; e; f; }
4+
5+
\problem { a & b & c -> d | e | f }
6+
7+
script: |
8+
macro "split-prop";
9+
hide "a ==> d, e";
10+
11+
goals:
12+
- "b, c ==> f"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "rule.exc"
2+
key: |
3+
\predicates { a; b; }
4+
\problem { a & b }
5+
6+
script: |
7+
rule andLeft;
8+
9+
exception: |
10+
Error while executing script: No matching applications.
11+
12+
Command: rule andLeft;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "selectFormula"
2+
key: |
3+
\predicates { a; b; c; }
4+
\problem { a & b & c}
5+
6+
script: |
7+
macro "split-prop";
8+
select formula="b";
9+
10+
goals:
11+
- "==> b"
12+
- "==> a"
13+
- "==> c"
14+
15+
selectedGoal: 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "unhide"
2+
key: |
3+
4+
\problem { 2=3 -> 3=4 }
5+
6+
script: |
7+
rule impRight;
8+
hide "2=3 ==> 3=4";
9+
unhide "2=3 ==>";
10+
unhide "==> 3=4";
11+
12+
goals:
13+
- "2 = 3 ==> 3 = 4"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: unhide2
2+
key: |
3+
4+
\problem { 2=3 -> 3=4 }
5+
6+
script: |
7+
rule impRight;
8+
hide "2=3 ==> 3=4";
9+
unhide "2=3 ==> 3=4";
10+
11+
goals:
12+
- 2 = 3 ==> 3 = 4

0 commit comments

Comments
 (0)