Skip to content

Commit 814d863

Browse files
committed
stonger tests
1 parent 6d611fc commit 814d863

15 files changed

+99
-42
lines changed

src/main/java/org/eolang/lints/comments/LtAsciiOnly.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Collection<Defect> defects(final XML xmir) throws IOException {
7070
xmir.xpath("/program/@name").stream().findFirst().orElse("unknown"),
7171
Integer.parseInt(line),
7272
String.format(
73-
"Only ASCII characters are allowed in comments, while '%s' is used at the %sth line at the %sth position",
73+
"Only ASCII characters are allowed in comments, while \"%s\" is used at the line no.%s at the position no.%s",
7474
chr,
7575
line,
7676
comment.xpath("text()").get(0).indexOf(chr) + 1

src/main/java/org/eolang/lints/critical/LtIncorrectAlias.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public Collection<Defect> defects(final Map<String, XML> pkg) {
8484
xmir.xpath("/program/metas/meta[head='alias'][1]/@line").get(0)
8585
),
8686
String.format(
87-
"Incorrect pointing alias '%s', since there is no %s",
87+
"Incorrect pointing alias \"%s\", since there is no \"%s\"",
8888
pointer,
8989
lookup
9090
)

src/main/java/org/eolang/lints/errors/LtAtomIsNotUnique.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private Defect singleDefect(final XML xmir, final String fqn, final int pos) {
156156
)
157157
).get(pos)
158158
),
159-
String.format("Atom '%s' is duplicated", fqn)
159+
String.format("Atom \"%s\" is duplicated", fqn)
160160
);
161161
}
162162

@@ -174,7 +174,7 @@ private Defect sharedDefect(final XML xmir, final XML original, final String fqn
174174
).get(0)
175175
),
176176
String.format(
177-
"Atom with FQN '%s' is duplicated, original was found in '%s'",
177+
"Atom with FQN \"%s\" is duplicated, original was found in \"%s\"",
178178
fqn, original.xpath("/program/@name").stream().findFirst().orElse("unknown")
179179
)
180180
);

src/main/java/org/eolang/lints/errors/LtObjectIsNotUnique.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public Collection<Defect> defects(final Map<String, XML> pkg) {
8282
.orElse("unknown"),
8383
Integer.parseInt(object.getValue()),
8484
String.format(
85-
"The object name '%s' is not unique, original object was found in '%s'",
85+
"The object name \"%s\" is not unique, original object was found in \"%s\"",
8686
object.getKey(), src
8787
)
8888
)

src/main/java/org/eolang/lints/units/LtUnitTestMissing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Collection<Defect> defects(final Map<String, XML> pkg) throws IOException
5555
Severity.WARNING,
5656
name,
5757
0,
58-
String.format("Unit test is not found for %s", name)
58+
String.format("Unit test is not found for \"%s\"", name)
5959
)
6060
);
6161
}

src/main/java/org/eolang/lints/units/LtUnitTestWithoutLiveFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Collection<Defect> defects(final Map<String, XML> pkg) {
6565
name,
6666
0,
6767
String.format(
68-
"Live .eo file '%s' was not found for '%s'", live, name
68+
"Live \".eo\" file \"%s\" was not found for \"%s\"", live, name
6969
)
7070
)
7171
);

src/test/java/org/eolang/lints/DefectMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* @since 0.0.34
3737
*/
38-
final class DefectMatcher extends BaseMatcher<Defect> {
38+
public final class DefectMatcher extends BaseMatcher<Defect> {
3939

4040
/**
4141
* Synthetic matcher that is built when input arrives.

src/test/java/org/eolang/lints/DefectsMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @since 0.0.34
3838
*/
39-
final class DefectsMatcher extends BaseMatcher<XML> {
39+
public final class DefectsMatcher extends BaseMatcher<XML> {
4040

4141
/**
4242
* Synthetic matcher that is built when input arrives.

src/test/java/org/eolang/lints/comments/LtAsciiOnlyTest.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
package org.eolang.lints.comments;
2525

2626
import java.io.IOException;
27-
import java.util.Collection;
2827
import org.cactoos.io.InputOf;
2928
import org.cactoos.list.ListOf;
3029
import org.eolang.lints.Defect;
30+
import org.eolang.lints.DefectMatcher;
3131
import org.eolang.parser.EoSyntax;
3232
import org.hamcrest.MatcherAssert;
3333
import org.hamcrest.Matchers;
@@ -42,23 +42,33 @@
4242
final class LtAsciiOnlyTest {
4343

4444
@Test
45-
void catchesNonAsciiInComment() throws IOException {
46-
final Collection<Defect> defects = new LtAsciiOnly().defects(
47-
new EoSyntax(
48-
new InputOf("# привет\n# как дела?\n[] > foo\n")
49-
).parsed()
50-
);
45+
void catchesSomeNonAsciiInComment() throws IOException {
5146
MatcherAssert.assertThat(
5247
"non-ascii comment is not welcome",
53-
defects,
54-
Matchers.hasSize(Matchers.greaterThan(0))
48+
new LtAsciiOnly().defects(
49+
new EoSyntax(
50+
new InputOf("# привет\n# как дела?\n[] > foo\n")
51+
).parsed()
52+
),
53+
Matchers.allOf(
54+
Matchers.<Defect>iterableWithSize(Matchers.greaterThan(0)),
55+
Matchers.<Defect>everyItem(new DefectMatcher())
56+
)
5557
);
58+
}
59+
60+
@Test
61+
void catchesNonAsciiInComment() throws IOException {
5662
MatcherAssert.assertThat(
5763
"non-ascii comment error should contain abusive character",
58-
new ListOf<>(defects).get(0).text(),
59-
Matchers.is(
60-
"Only ASCII characters are allowed in comments, while 'п' is used at the 3th line at the 1th position"
61-
)
64+
new ListOf<>(
65+
new LtAsciiOnly().defects(
66+
new EoSyntax(
67+
new InputOf("# привет\n# как дела?\n[] > foo\n")
68+
).parsed()
69+
)
70+
).get(0).text(),
71+
Matchers.containsString("Only ASCII characters are allowed in comments")
6272
);
6373
}
6474

src/test/java/org/eolang/lints/critical/LtIncorrectAliasTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import java.nio.file.Path;
3232
import org.cactoos.map.MapEntry;
3333
import org.cactoos.map.MapOf;
34+
import org.eolang.lints.Defect;
35+
import org.eolang.lints.DefectMatcher;
3436
import org.eolang.lints.ParsedEo;
3537
import org.eolang.lints.Programs;
3638
import org.hamcrest.MatcherAssert;
@@ -61,7 +63,10 @@ void catchesBrokenAlias() throws Exception {
6163
)
6264
)
6365
),
64-
Matchers.hasSize(Matchers.greaterThan(0))
66+
Matchers.allOf(
67+
Matchers.<Defect>iterableWithSize(Matchers.greaterThan(0)),
68+
Matchers.<Defect>everyItem(new DefectMatcher())
69+
)
6570
);
6671
}
6772

0 commit comments

Comments
 (0)