Skip to content

Commit

Permalink
objectionary#2937 add empty assertion message in eo-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Mar 25, 2024
1 parent a6e15d6 commit 5472352
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java
Expand Up @@ -35,13 +35,19 @@
* @since 1.0
*/
final class EoIndentLexerTest {
/**
* Empty message for JUnit Assertions.
*/
private static final String EMPTY_MSG = "EMPTY MESSAGE";

@Test
void emitsTab() throws IOException {
final EoIndentLexer lexer = new EoIndentLexer(
new TextOf("\n ")
);
lexer.nextToken();
MatcherAssert.assertThat(
EoIndentLexerTest.EMPTY_MSG,
lexer.nextToken().getType(),
Matchers.is(
EoParser.TAB
Expand All @@ -55,6 +61,7 @@ void ensuresGrammarFile() throws IOException {
new TextOf("")
);
MatcherAssert.assertThat(
EoIndentLexerTest.EMPTY_MSG,
lexer.getGrammarFileName(),
Matchers.is(
"Eo.g4"
Expand All @@ -69,6 +76,7 @@ void emitsTabWhenEmptyLine() throws IOException {
);
lexer.nextToken();
MatcherAssert.assertThat(
EoIndentLexerTest.EMPTY_MSG,
lexer.nextToken().getType(),
Matchers.is(
EoParser.TAB
Expand All @@ -85,6 +93,7 @@ void emitsUntab() throws IOException {
lexer.nextToken();
lexer.nextToken();
MatcherAssert.assertThat(
EoIndentLexerTest.EMPTY_MSG,
lexer.nextToken().getType(),
Matchers.is(
EoParser.UNTAB
Expand All @@ -98,6 +107,7 @@ void readsEmptyString() throws IOException {
new TextOf("")
);
MatcherAssert.assertThat(
EoIndentLexerTest.EMPTY_MSG,
lexer.nextToken().getType(),
Matchers.is(
EoParser.EOF
Expand Down
15 changes: 15 additions & 0 deletions eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java
Expand Up @@ -50,9 +50,15 @@
*/
@SuppressWarnings("PMD.TooManyMethods")
final class EoSyntaxTest {
/**
* Empty message for JUnit Assertions.
*/
private static final String EMPTY_MSG = "EMPTY MESSAGE";

@Test
void parsesSimpleCode() throws Exception {
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
XhtmlMatchers.xhtml(
new String(
new EoSyntax(
Expand Down Expand Up @@ -86,6 +92,7 @@ void containsCommentCheckErrors(
final String message
) throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
XhtmlMatchers.xhtml(
new String(
new EoSyntax(
Expand Down Expand Up @@ -118,6 +125,7 @@ void printsProperListingEvenWhenSyntaxIsBroken() throws Exception {
"[] > x-薪, 1\n"
);
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
XhtmlMatchers.xhtml(
new String(
new EoSyntax(
Expand Down Expand Up @@ -149,6 +157,7 @@ void copiesListingCorrectly() throws Exception {
)
);
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
xml.xpath("/program/listing/text()"),
Matchers.contains(src)
);
Expand Down Expand Up @@ -178,6 +187,7 @@ void parsesSuccessfully(final String code) {
@Test
void parsesArrow() throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
new EoSyntax(
"test-it-3",
new InputOf("1 > x")
Expand All @@ -201,6 +211,7 @@ void prasesNested() throws IOException {
" v\n"
);
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
new EoSyntax(
"test-it-4",
new InputOf(src)
Expand All @@ -215,6 +226,7 @@ void prasesNested() throws IOException {
@Test
void parsesDefinition() throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
new EoSyntax(
"test-it-5",
new InputOf(
Expand All @@ -236,6 +248,7 @@ void parsesDefinition() throws IOException {
@Test
void parsesMethodCalls() throws IOException {
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
new EoSyntax(
"test-it-1",
new InputOf("add.\n 0\n TRUE")
Expand Down Expand Up @@ -265,6 +278,7 @@ void storesAsBytes(final String code) throws IOException {
)
);
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
xml,
XhtmlMatchers.hasXPaths(
"/program/objects[count(o)=1]",
Expand All @@ -284,6 +298,7 @@ void checksTypoPacks(final String yml) throws IOException, NumberFormatException
new InputOf(String.format("%s\n", map.get("eo")))
).parsed();
MatcherAssert.assertThat(
EoSyntaxTest.EMPTY_MSG,
XhtmlMatchers.xhtml(xml.toString()),
XhtmlMatchers.hasXPaths("/program/errors/error/@line")
);
Expand Down
3 changes: 3 additions & 0 deletions eo-parser/src/test/java/org/eolang/parser/ObjectsTest.java
Expand Up @@ -43,6 +43,7 @@ void parsesOneObject() {
objs.data("xxx");
objs.leave();
MatcherAssert.assertThat(
"EMPTY MESSAGE",
new XMLDocument(new Xembler(objs).domQuietly()),
XhtmlMatchers.hasXPaths(
"/o",
Expand All @@ -64,6 +65,7 @@ void parsesNestedObjects() {
objs.leave();
objs.leave();
MatcherAssert.assertThat(
"EMPTY MESSAGE",
new XMLDocument(new Xembler(objs).domQuietly()),
XhtmlMatchers.hasXPaths(
"/o",
Expand All @@ -82,6 +84,7 @@ void parsesObjectsWithEnteringPrevious() {
objs.enter();
objs.prop("z", "a");
MatcherAssert.assertThat(
"EMPTY MESSAGE",
new XMLDocument(new Xembler(objs).domQuietly()),
XhtmlMatchers.hasXPaths(
"/o/o",
Expand Down
13 changes: 12 additions & 1 deletion eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java
Expand Up @@ -35,10 +35,15 @@
* @since 0.29.0
*/
final class StUnhexTest {

/**
* Empty message for JUnit Assertions.
*/
private static final String EMPTY_MSG = "EMPTY MESSAGE";

@Test
void convertsIntFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
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 @@ -51,6 +56,7 @@ void convertsIntFromHexToEo() {
@Test
void convertsMaxIntFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
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 @@ -63,6 +69,7 @@ void convertsMaxIntFromHexToEo() {
@Test
void convertsStringFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
new Xsline(new StUnhex()).pass(
new XMLDocument(
String.join(
Expand All @@ -82,6 +89,7 @@ void convertsStringFromHexToEo() {
@Test
void convertsEmptyStringFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='string'><o base='bytes' data='bytes'/></o></p>"
Expand All @@ -96,6 +104,7 @@ void convertsEmptyStringFromHexToEo() {
@Test
void convertsFloatFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
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 @@ -110,6 +119,7 @@ void convertsFloatFromHexToEo() {
@Test
void convertsTrueFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
new Xsline(new StUnhex()).pass(
new XMLDocument(
String.join(
Expand All @@ -129,6 +139,7 @@ void convertsTrueFromHexToEo() {
@Test
void convertsFalseFromHexToEo() {
MatcherAssert.assertThat(
StUnhexTest.EMPTY_MSG,
new Xsline(new StUnhex()).pass(
new XMLDocument(
"<p><o base='bool'><o base='org.eolang.bytes' data='bytes'>00</o></o></p>"
Expand Down
1 change: 1 addition & 0 deletions eo-parser/src/test/java/org/eolang/parser/StXPathTest.java
Expand Up @@ -41,6 +41,7 @@ final class StXPathTest {
@Test
void modifiesSimpleNode() {
MatcherAssert.assertThat(
"EMPTY MESSAGE",
new Xsline(
new StEndless(
new StXPath(
Expand Down

0 comments on commit 5472352

Please sign in to comment.