Skip to content

Commit 5855bd5

Browse files
committed
Test checkstyle fixes
1 parent 382b96f commit 5855bd5

File tree

12 files changed

+403
-405
lines changed

12 files changed

+403
-405
lines changed

src/test/java/io/github/syst3ms/skriptparser/TestAddon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.Map;
1212

1313
public class TestAddon extends SkriptAddon {
14-
private final Map<String,List<Trigger>> testTriggers = new HashMap<>();
14+
private final Map<String, List<Trigger>> testTriggers = new HashMap<>();
1515

1616
public TestAddon(String name) {
1717
super(name);

src/test/java/io/github/syst3ms/skriptparser/TestRegistration.java

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,47 @@
1414

1515
public class TestRegistration {
1616

17-
public static void register() {
18-
try {
19-
Field regField = Parser.class.getDeclaredField("registration");
20-
regField.setAccessible(true);
21-
String s = new Random().nextInt(10000) + "-addon";
22-
regField.set(null, new SkriptRegistration(new TestAddon(s)));
23-
} catch (NoSuchFieldException | IllegalAccessException e) {
24-
e.printStackTrace();
25-
}
26-
DefaultRegistration.register();
27-
try {
28-
FileUtils.loadClasses(
29-
Path.of("build/classes/java/main"),
30-
"io.github.syst3ms.skriptparser",
31-
"effects",
32-
"expressions",
33-
"lang",
34-
"sections",
35-
"tags"
36-
);
37-
FileUtils.loadClasses(
38-
Path.of("build/classes/java/test"),
39-
"io.github.syst3ms.skriptparser",
40-
"syntax"
41-
);
42-
} catch (IOException e) {
43-
e.printStackTrace();
44-
}
45-
Parser.getMainRegistration().register();
17+
public static void register() {
18+
try {
19+
Field regField = Parser.class.getDeclaredField("registration");
20+
regField.setAccessible(true);
21+
String s = new Random().nextInt(10000) + "-addon";
22+
regField.set(null, new SkriptRegistration(new TestAddon(s)));
23+
} catch (NoSuchFieldException | IllegalAccessException e) {
24+
e.printStackTrace();
25+
}
26+
DefaultRegistration.register();
27+
try {
28+
FileUtils.loadClasses(
29+
Path.of("build/classes/java/main"),
30+
"io.github.syst3ms.skriptparser",
31+
"effects",
32+
"expressions",
33+
"lang",
34+
"sections",
35+
"tags"
36+
);
37+
FileUtils.loadClasses(
38+
Path.of("build/classes/java/test"),
39+
"io.github.syst3ms.skriptparser",
40+
"syntax"
41+
);
42+
} catch (IOException e) {
43+
e.printStackTrace();
44+
}
45+
Parser.getMainRegistration().register();
4646

47-
/*
48-
* Now, we need to change some fields to keep all tests consistent.
49-
*/
47+
/*
48+
* Now, we need to change some fields to keep all tests consistent.
49+
*/
5050

51-
// defaultTimezone field
52-
try {
53-
Field timeZone = SkriptDate.class.getDeclaredField("defaultTimeZone");
54-
timeZone.setAccessible(true);
55-
timeZone.set(null, TimeZone.getTimeZone(ZoneOffset.UTC));
56-
} catch (NoSuchFieldException | IllegalAccessException e) {
57-
e.printStackTrace();
58-
}
59-
}
51+
// defaultTimezone field
52+
try {
53+
Field timeZone = SkriptDate.class.getDeclaredField("defaultTimeZone");
54+
timeZone.setAccessible(true);
55+
timeZone.set(null, TimeZone.getTimeZone(ZoneOffset.UTC));
56+
} catch (NoSuchFieldException | IllegalAccessException e) {
57+
e.printStackTrace();
58+
}
59+
}
6060
}

src/test/java/io/github/syst3ms/skriptparser/file/FileParserTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public void parseFileLines() {
6363
assertEquals(
6464
expected,
6565
parseLines(Arrays.asList(
66-
"nested sections",
67-
"section:",
68-
"\tother section:",
69-
"\t\telement"
70-
))
66+
"nested sections",
67+
"section:",
68+
"\tother section:",
69+
"\t\telement"
70+
))
7171
);
7272
expected = Arrays.asList(
7373
simpleFileLine("elements after section", 0, 1),

src/test/java/io/github/syst3ms/skriptparser/parsing/PatternParserTest.java

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class PatternParserTest {
2626
static {
2727
TestRegistration.register();
2828
}
29-
29+
3030
private <T> void assertEqualsOptional(T expected, Optional<? extends T> actual) {
3131
assertTrue(actual.filter(expected::equals).isPresent());
3232
}
@@ -45,147 +45,147 @@ public void testParsePattern() {
4545

4646
// Nested optionals
4747
assertEqualsOptional(
48-
new OptionalGroup(
49-
new CompoundElement(
50-
new TextElement("nested "),
51-
new OptionalGroup(new TextElement("optional"))
52-
)
53-
),
54-
parsePattern("[nested [optional]]", logger)
48+
new OptionalGroup(
49+
new CompoundElement(
50+
new TextElement("nested "),
51+
new OptionalGroup(new TextElement("optional"))
52+
)
53+
),
54+
parsePattern("[nested [optional]]", logger)
5555
);
5656

5757
// Choice groups with parse marks
5858
assertEqualsOptional(
59-
new ChoiceGroup(
60-
new ChoiceElement(new TextElement("single choice"), null)
61-
),
62-
parsePattern("(single choice)", logger)
59+
new ChoiceGroup(
60+
new ChoiceElement(new TextElement("single choice"), null)
61+
),
62+
parsePattern("(single choice)", logger)
6363
);
6464
assertEqualsOptional(
65-
new ChoiceGroup(
66-
new ChoiceElement(new TextElement("parse mark"), "1")
67-
),
68-
parsePattern("(1:parse mark)", logger)
65+
new ChoiceGroup(
66+
new ChoiceElement(new TextElement("parse mark"), "1")
67+
),
68+
parsePattern("(1:parse mark)", logger)
6969
);
7070
assertEqualsOptional(
71-
new ChoiceGroup(
72-
new ChoiceElement(
73-
new CompoundElement(
74-
new TextElement("simplified "),
75-
new OptionalGroup(
76-
new TextElement("mark")
77-
)
78-
),
79-
"simplified"
71+
new ChoiceGroup(
72+
new ChoiceElement(
73+
new CompoundElement(
74+
new TextElement("simplified "),
75+
new OptionalGroup(
76+
new TextElement("mark")
8077
)
81-
),
82-
parsePattern("(:simplified [mark])", logger)
78+
),
79+
"simplified"
80+
)
81+
),
82+
parsePattern("(:simplified [mark])", logger)
8383
);
8484
assertEqualsOptional(
85-
new ChoiceGroup(
86-
new ChoiceElement(new TextElement("first choice"), null),
87-
new ChoiceElement(new TextElement("second choice"), null)
88-
),
89-
parsePattern("(first choice|second choice)", logger)
85+
new ChoiceGroup(
86+
new ChoiceElement(new TextElement("first choice"), null),
87+
new ChoiceElement(new TextElement("second choice"), null)
88+
),
89+
parsePattern("(first choice|second choice)", logger)
9090
);
9191
assertEqualsOptional(
92-
new ChoiceGroup(
93-
new ChoiceElement(new TextElement("first mark"), null),
94-
new ChoiceElement(new TextElement("second mark"), "1")
95-
),
96-
parsePattern("(first mark|1:second mark)", logger)
92+
new ChoiceGroup(
93+
new ChoiceElement(new TextElement("first mark"), null),
94+
new ChoiceElement(new TextElement("second mark"), "1")
95+
),
96+
parsePattern("(first mark|1:second mark)", logger)
9797
);
9898
assertEqualsOptional(
99-
new ChoiceGroup(
100-
new ChoiceElement(new TextElement("first choice "), "first choice"),
101-
new ChoiceElement(new TextElement("second choice"), "second choice")
102-
),
103-
parsePattern(":(first choice |second choice)", logger)
99+
new ChoiceGroup(
100+
new ChoiceElement(new TextElement("first choice "), "first choice"),
101+
new ChoiceElement(new TextElement("second choice"), "second choice")
102+
),
103+
parsePattern(":(first choice |second choice)", logger)
104104
);
105105
assertEqualsOptional(
106-
new ChoiceGroup(
107-
new ChoiceElement(new TextElement("first mark"), null),
108-
new ChoiceElement(new TextElement("second mark"), "second mark")
109-
),
110-
parsePattern("(first mark|:second mark)", logger)
106+
new ChoiceGroup(
107+
new ChoiceElement(new TextElement("first mark"), null),
108+
new ChoiceElement(new TextElement("second mark"), "second mark")
109+
),
110+
parsePattern("(first mark|:second mark)", logger)
111111
);
112112
assertEqualsOptional(
113-
new ChoiceGroup(
114-
new ChoiceElement(new TextElement("first mark"), null),
115-
new ChoiceElement(new TextElement("second mark"), "second mark"),
116-
new ChoiceElement(new TextElement("third custom mark"), "custom"),
117-
new ChoiceElement(new TextElement("fourth mark"), null)
118-
),
119-
parsePattern("(first mark|:second mark|custom:third custom mark|fourth mark)", logger)
113+
new ChoiceGroup(
114+
new ChoiceElement(new TextElement("first mark"), null),
115+
new ChoiceElement(new TextElement("second mark"), "second mark"),
116+
new ChoiceElement(new TextElement("third custom mark"), "custom"),
117+
new ChoiceElement(new TextElement("fourth mark"), null)
118+
),
119+
parsePattern("(first mark|:second mark|custom:third custom mark|fourth mark)", logger)
120120
);
121121

122122
// Optional choice group (syntax sugar)
123123
assertEqualsOptional(
124-
new OptionalGroup(
125-
new ChoiceGroup(
126-
new ChoiceElement(new TextElement("one"), "one"),
127-
new ChoiceElement(new TextElement(" two"), "two"),
128-
new ChoiceElement(new TextElement("three"), "four")
129-
)
130-
),
131-
parsePattern(":[one| two|four:three]", logger)
124+
new OptionalGroup(
125+
new ChoiceGroup(
126+
new ChoiceElement(new TextElement("one"), "one"),
127+
new ChoiceElement(new TextElement(" two"), "two"),
128+
new ChoiceElement(new TextElement("three"), "four")
129+
)
130+
),
131+
parsePattern(":[one| two|four:three]", logger)
132132
);
133133

134134
// Optional with nested group with parse marks
135135
assertEqualsOptional(
136-
new OptionalGroup(
137-
new ChoiceGroup(
138-
new ChoiceElement(
139-
new CompoundElement(
140-
new TextElement("optional "),
141-
new ChoiceGroup(
142-
new ChoiceElement(new TextElement("first choice"), null),
143-
new ChoiceElement(new TextElement("second choice"), "second")
144-
)
145-
),
146-
"optional"
147-
)
148-
)
149-
),
150-
parsePattern("[:optional (first choice|second:second choice)]", logger)
136+
new OptionalGroup(
137+
new ChoiceGroup(
138+
new ChoiceElement(
139+
new CompoundElement(
140+
new TextElement("optional "),
141+
new ChoiceGroup(
142+
new ChoiceElement(new TextElement("first choice"), null),
143+
new ChoiceElement(new TextElement("second choice"), "second")
144+
)
145+
),
146+
"optional"
147+
)
148+
)
149+
),
150+
parsePattern("[:optional (first choice|second:second choice)]", logger)
151151
);
152152

153153
// Regex group
154154
assertEqualsOptional(
155-
new RegexGroup(Pattern.compile(".+")),
156-
parsePattern("<.+>", logger)
155+
new RegexGroup(Pattern.compile(".+")),
156+
parsePattern("<.+>", logger)
157157
);
158158
assertEqualsOptional(
159-
new RegexGroup(Pattern.compile("(\\d*1)st|(\\d*2)nd|(\\d*3)rd|(\\d*[4-90])th")),
160-
parsePattern("<(\\d*1)st|(\\d*2)nd|(\\d*3)rd|(\\d*[4-90])th>", logger)
159+
new RegexGroup(Pattern.compile("(\\d*1)st|(\\d*2)nd|(\\d*3)rd|(\\d*[4-90])th")),
160+
parsePattern("<(\\d*1)st|(\\d*2)nd|(\\d*3)rd|(\\d*[4-90])th>", logger)
161161
);
162162

163163
// Expression elements
164164
assertEqualsOptional(
165-
new ExpressionElement(
166-
Collections.singletonList(TypeManager.getPatternType("number").orElseThrow(AssertionError::new)),
167-
ExpressionElement.Acceptance.ALL,
168-
false,
169-
false
170-
),
171-
parsePattern("%number%", logger)
165+
new ExpressionElement(
166+
Collections.singletonList(TypeManager.getPatternType("number").orElseThrow(AssertionError::new)),
167+
ExpressionElement.Acceptance.ALL,
168+
false,
169+
false
170+
),
171+
parsePattern("%number%", logger)
172172
);
173173
assertEqualsOptional(
174-
new ExpressionElement(
175-
Arrays.asList(
176-
TypeManager.getPatternType("number").orElseThrow(AssertionError::new),
177-
TypeManager.getPatternType("strings").orElseThrow(AssertionError::new)
178-
),
179-
ExpressionElement.Acceptance.LITERALS_ONLY,
180-
true,
181-
false
174+
new ExpressionElement(
175+
Arrays.asList(
176+
TypeManager.getPatternType("number").orElseThrow(AssertionError::new),
177+
TypeManager.getPatternType("strings").orElseThrow(AssertionError::new)
182178
),
183-
parsePattern("%*number/strings%", logger)
179+
ExpressionElement.Acceptance.LITERALS_ONLY,
180+
true,
181+
false
182+
),
183+
parsePattern("%*number/strings%", logger)
184184
);
185185

186186
// Failing patterns
187187
assertOptionalEmpty(parsePattern("(unclosed", logger));
188188
assertOptionalEmpty(parsePattern("%unfinished type", logger));
189189
}
190190

191-
}
191+
}

0 commit comments

Comments
 (0)