Skip to content

Commit

Permalink
#2297 resolve empty message duplication for eo-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Apr 19, 2024
1 parent e89c483 commit 4c24b95
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
Expand Up @@ -54,7 +54,7 @@
public final class BinarizeParseTest {

/**
* Empty message for JUnit Assertions. To be removed.
* Empty message for JUnit Assertions.
*/
public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

Expand Down
10 changes: 8 additions & 2 deletions eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java
Expand Up @@ -33,12 +33,18 @@
* Test for {@link EoIndentLexer}.
*
* @since 1.0
*
* @todo #2297:60m Replace all appearances of {@link EoIndentLexerTest#TO_ADD_MESSAGE} field in
* eo-parser with meaningful assert messages. Don't forget to remove
* {@link EoIndentLexerTest#TO_ADD_MESSAGE} field and remove public modifier from this class if no
* longer need.
*/
final class EoIndentLexerTest {
@SuppressWarnings("PMD.JUnit5TestShouldBePackagePrivate")
public final class EoIndentLexerTest {
/**
* Empty message for JUnit Assertions.
*/
private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";
public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

@Test
void emitsTab() throws IOException {
Expand Down
26 changes: 11 additions & 15 deletions eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java
Expand Up @@ -50,15 +50,11 @@
*/
@SuppressWarnings("PMD.TooManyMethods")
final class EoSyntaxTest {
/**
* Empty message for JUnit Assertions.
*/
private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

@Test
void parsesSimpleCode() throws Exception {
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
XhtmlMatchers.xhtml(
new String(
new EoSyntax(
Expand Down Expand Up @@ -92,7 +88,7 @@ void containsCommentCheckErrors(
final String message
) throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
XhtmlMatchers.xhtml(
new String(
new EoSyntax(
Expand Down Expand Up @@ -125,7 +121,7 @@ void printsProperListingEvenWhenSyntaxIsBroken() throws Exception {
"[] > x-薪, 1\n"
);
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
XhtmlMatchers.xhtml(
new String(
new EoSyntax(
Expand Down Expand Up @@ -157,7 +153,7 @@ void copiesListingCorrectly() throws Exception {
)
);
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
xml.xpath("/program/listing/text()"),
Matchers.contains(src)
);
Expand All @@ -181,14 +177,14 @@ void parsesSuccessfully(final String code) {
);
Assertions.assertDoesNotThrow(
syntax::parsed,
EoSyntaxTest.TO_ADD_MESSAGE
EoIndentLexerTest.TO_ADD_MESSAGE
);
}

@Test
void parsesArrow() throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new EoSyntax(
"test-it-3",
new InputOf("1 > x")
Expand All @@ -212,7 +208,7 @@ void prasesNested() throws IOException {
" v\n"
);
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new EoSyntax(
"test-it-4",
new InputOf(src)
Expand All @@ -227,7 +223,7 @@ void prasesNested() throws IOException {
@Test
void parsesDefinition() throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new EoSyntax(
"test-it-5",
new InputOf(
Expand All @@ -249,7 +245,7 @@ void parsesDefinition() throws IOException {
@Test
void parsesMethodCalls() throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new EoSyntax(
"test-it-1",
new InputOf("add.\n 0\n true")
Expand Down Expand Up @@ -279,7 +275,7 @@ void storesAsBytes(final String code) throws IOException {
)
);
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
xml,
XhtmlMatchers.hasXPaths(
"/program/objects[count(o)=1]",
Expand All @@ -299,7 +295,7 @@ void checksTypoPacks(final String yml) throws IOException {
new InputOf(String.format("%s\n", map.get("eo")))
).parsed();
MatcherAssert.assertThat(
EoSyntaxTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
XhtmlMatchers.xhtml(xml.toString()),
XhtmlMatchers.hasXPaths("/program/errors/error/@line")
);
Expand Down
6 changes: 3 additions & 3 deletions eo-parser/src/test/java/org/eolang/parser/ObjectsTest.java
Expand Up @@ -43,7 +43,7 @@ void parsesOneObject() {
objs.data("xxx");
objs.leave();
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
EoIndentLexerTest.TO_ADD_MESSAGE,
new XMLDocument(new Xembler(objs).domQuietly()),
XhtmlMatchers.hasXPaths(
"/o",
Expand All @@ -65,7 +65,7 @@ void parsesNestedObjects() {
objs.leave();
objs.leave();
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
EoIndentLexerTest.TO_ADD_MESSAGE,
new XMLDocument(new Xembler(objs).domQuietly()),
XhtmlMatchers.hasXPaths(
"/o",
Expand All @@ -84,7 +84,7 @@ void parsesObjectsWithEnteringPrevious() {
objs.enter();
objs.prop("z", "a");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
EoIndentLexerTest.TO_ADD_MESSAGE,
new XMLDocument(new Xembler(objs).domQuietly()),
XhtmlMatchers.hasXPaths(
"/o/o",
Expand Down
18 changes: 7 additions & 11 deletions eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java
Expand Up @@ -35,15 +35,11 @@
* @since 0.29.0
*/
final class StUnhexTest {
/**
* Empty message for JUnit Assertions.
*/
private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

@Test
void convertsIntFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='int'><o base='org.eolang.bytes' data='bytes'>01 02 E4 F3 04 67 32 E1</o></o></p>"
Expand All @@ -56,7 +52,7 @@ void convertsIntFromHexToEo() {
@Test
void convertsMaxIntFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='int'><o base='org.eolang.bytes' data='bytes'>FF FF FF FF FF FF FF FF</o></o></p>"
Expand All @@ -69,7 +65,7 @@ void convertsMaxIntFromHexToEo() {
@Test
void convertsStringFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
String.join(
Expand All @@ -89,7 +85,7 @@ void convertsStringFromHexToEo() {
@Test
void convertsEmptyStringFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='string'><o base='bytes' data='bytes'/></o></p>"
Expand All @@ -104,7 +100,7 @@ void convertsEmptyStringFromHexToEo() {
@Test
void convertsFloatFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='float'><o base='org.eolang.bytes' data='bytes'>41 42 43 67 AE CD 3E FD</o></o></p>"
Expand All @@ -119,7 +115,7 @@ void convertsFloatFromHexToEo() {
@Test
void convertsTrueFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
String.join(
Expand All @@ -139,7 +135,7 @@ void convertsTrueFromHexToEo() {
@Test
void convertsFalseFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.TO_ADD_MESSAGE,
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='bool'><o base='org.eolang.bytes' data='bytes'>00</o></o></p>"
Expand Down
2 changes: 1 addition & 1 deletion eo-parser/src/test/java/org/eolang/parser/StXPathTest.java
Expand Up @@ -41,7 +41,7 @@ final class StXPathTest {
@Test
void modifiesSimpleNode() {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
EoIndentLexerTest.TO_ADD_MESSAGE,
new Xsline(
new StEndless(
new StXPath(
Expand Down
3 changes: 1 addition & 2 deletions eo-runtime/src/test/java/org/eolang/AtCompositeTest.java
Expand Up @@ -34,7 +34,6 @@
*
* @since 0.16
*
*
* @todo #2297:60m Replace all appearances of {@link AtCompositeTest#TO_ADD_MESSAGE} field in
* eo-runtime with meaningful assert messages. Don't forget to remove
* {@link AtCompositeTest#TO_ADD_MESSAGE} field and remove public modifier from this class if no
Expand All @@ -45,7 +44,7 @@ public final class AtCompositeTest {
/**
* Empty message for JUnit Assertions. To be removed.
*/
public static final String TO_ADD_MESSAGE = AtCompositeTest.TO_ADD_MESSAGE;
public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

@Test
void decoratesCheckedException() {
Expand Down

0 comments on commit 4c24b95

Please sign in to comment.