Skip to content

Commit 845a186

Browse files
Check the generated names with one message test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 36ef288 commit 845a186

2 files changed

Lines changed: 12 additions & 98 deletions

File tree

‎liquidjava-verifier/src/test/java/liquidjava/api/tests/TestGeneratedNames.java‎

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5-
import java.util.List;
65
import java.util.Map;
7-
import java.util.TreeMap;
86
import java.util.stream.Collectors;
97

10-
import org.junit.jupiter.api.BeforeAll;
118
import org.junit.jupiter.api.Test;
129

1310
import liquidjava.api.CommandLineLauncher;
@@ -19,61 +16,18 @@
1916
*/
2017
class TestGeneratedNames {
2118

22-
private static Map<Integer, String> messages;
23-
24-
@BeforeAll
25-
static void verify() {
26-
CommandLineLauncher.launch("../liquidjava-example/src/main/java/testSuite/classes/generated_names_error");
27-
// a second error on a line fails here instead of replacing the first
28-
messages = Diagnostics.getInstance().getErrors().stream().collect(
29-
Collectors.toMap(error -> error.getPosition().getLine(), error -> plain(error.getMessage()), (a, b) -> {
30-
throw new AssertionError("two errors on one line: " + a + " and " + b);
31-
}, TreeMap::new));
32-
}
33-
34-
@Test
35-
void reportsOneErrorPerOrigin() {
36-
assertEquals(List.of(25, 30, 34, 43, 48, 54, 58), List.copyOf(messages.keySet()));
37-
}
38-
39-
@Test
40-
void ifConditionIsNamedAfterTheIf() {
41-
assertEquals("#if_condition == ready && #if_condition is not a subtype of a > 0", messages.get(25));
42-
}
43-
44-
@Test
45-
void loopConditionIsNamedAfterTheLoop() {
46-
assertEquals("#loop_condition == ready && #loop_condition == true is not a subtype of a > 0", messages.get(30));
47-
}
48-
49-
@Test
50-
void ternaryConditionIsNamedAfterTheTernary() {
51-
assertEquals("#ternary_condition == ready && #ternary_condition == true is not a subtype of a < 0",
52-
messages.get(34));
53-
}
54-
55-
@Test
56-
void tryAndCatchPathsAreNamedAfterTheirBranches() {
57-
assertEquals("!#try_branch && !#catch_branch is not a subtype of a > 0", messages.get(43));
58-
}
59-
60-
@Test
61-
void callResultIsNamedAfterTheMethod() {
62-
assertEquals("x == #read_result - 1 is not a subtype of x > 0", messages.get(48));
63-
}
64-
65-
@Test
66-
void untranslatedOperationIsNamedAsAnOperationResult() {
67-
assertEquals("#if_condition == #operation_result && #if_condition && x == 0 is not a subtype of x > 0",
68-
messages.get(54));
69-
}
70-
7119
@Test
72-
void newReceiverIsNamedAfterItsClass() {
73-
assertEquals("found closed(#new_Door) but expected opened(#new_Door)", messages.get(58));
74-
}
75-
76-
private static String plain(String text) {
77-
return text.replaceAll("[⁰¹²³⁴⁵⁶⁷⁸⁹]", "");
20+
void namesEachGeneratedValueAfterWhatItIs() {
21+
CommandLineLauncher.launch("../liquidjava-example/src/main/java/testSuite/classes/generated_names_error");
22+
Map<Integer, String> messages = Diagnostics.getInstance().getErrors().stream().collect(Collectors.toMap(
23+
error -> error.getPosition().getLine(), error -> error.getMessage().replaceAll("[⁰¹²³⁴⁵⁶⁷⁸⁹]", "")));
24+
25+
assertEquals(Map.of(25, "#if_condition == ready && #if_condition is not a subtype of a > 0", 30,
26+
"#loop_condition == ready && #loop_condition == true is not a subtype of a > 0", 34,
27+
"#ternary_condition == ready && #ternary_condition == true is not a subtype of a < 0", 43,
28+
"!#try_branch && !#catch_branch is not a subtype of a > 0", 48,
29+
"x == #read_result - 1 is not a subtype of x > 0", 54,
30+
"#if_condition == #operation_result && #if_condition && x == 0 is not a subtype of x > 0", 58,
31+
"found closed(#new_Door) but expected opened(#new_Door)"), messages);
7832
}
7933
}

‎liquidjava-verifier/src/test/java/liquidjava/utils/GeneratedNamesTest.java‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)