From 76bf5a09d4929e08bde14e5dafe5da236cb9750d Mon Sep 17 00:00:00 2001 From: volodya-lombrozo Date: Wed, 25 Dec 2024 16:03:33 +0300 Subject: [PATCH] feat(#3756): fix test cases according with the new formatting --- .../src/main/java/org/eolang/parser/LocationMessage.java | 6 +++++- .../org/eolang/parser/eo-typos/binding-with-rho.yaml | 2 +- .../resources/org/eolang/parser/eo-typos/broken-head.yaml | 2 +- .../org/eolang/parser/eo-typos/comment-in-method.yaml | 2 +- .../org/eolang/parser/eo-typos/double-empty-lines.yaml | 5 +++-- .../org/eolang/parser/eo-typos/double-space-in-meta.yaml | 2 +- .../eolang/parser/eo-typos/empty-line-between-metas.yaml | 2 +- .../parser/eo-typos/missing-empty-line-after-metas.yaml | 2 +- .../org/eolang/parser/eo-typos/not-empty-atoms.yaml | 2 +- .../redundant-parentheses/simple-application-named.yaml | 2 +- .../eo-typos/redundant-parentheses/simple-application.yaml | 2 +- .../resources/org/eolang/parser/eo-typos/two-spaces.yaml | 2 +- .../eolang/parser/eo-typos/vmethod-after-happlication.yaml | 2 +- .../org/eolang/parser/eo-typos/vmethod-after-hmethod.yaml | 2 +- 14 files changed, 20 insertions(+), 15 deletions(-) diff --git a/eo-parser/src/main/java/org/eolang/parser/LocationMessage.java b/eo-parser/src/main/java/org/eolang/parser/LocationMessage.java index 80e9b20b72..665bb41265 100644 --- a/eo-parser/src/main/java/org/eolang/parser/LocationMessage.java +++ b/eo-parser/src/main/java/org/eolang/parser/LocationMessage.java @@ -23,6 +23,10 @@ */ package org.eolang.parser; +/** + * Error message that includes the location of the error. + * @since 0.50 + */ final class LocationMessage { /** @@ -57,6 +61,6 @@ final class LocationMessage { * @return The formatted error message. */ String formatted() { - return String.format("[%d:%d] error: \"%s\"", this.line, this.position, this.message); + return String.format("[%d:%d] error: '%s'", this.line, this.position, this.message); } } diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/binding-with-rho.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/binding-with-rho.yaml index cdfb53e8dc..e26648c246 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/binding-with-rho.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/binding-with-rho.yaml @@ -22,7 +22,7 @@ --- line: 2 message: >- - [2:4] error: Invalid object declaration: + [2:4] error: 'Invalid object declaration' y:^ ^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/broken-head.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/broken-head.yaml index f3c36fb615..6fd20024e8 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/broken-head.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/broken-head.yaml @@ -22,7 +22,7 @@ --- line: 2 message: |- - [2:7] error: Invalid object declaration: + [2:7] error: 'Invalid object declaration' [] > a [] > b [] > c [] > d hello world ^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/comment-in-method.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/comment-in-method.yaml index faf260bb1d..a23d4d38a9 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/comment-in-method.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/comment-in-method.yaml @@ -25,7 +25,7 @@ line: 5 # comment. The error message should be updated to point to the exact position # of the comment. message: | - [5:12] error: Invalid object declaration: + [5:12] error: 'Invalid object declaration' sprintwf input: | # No comments diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-empty-lines.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-empty-lines.yaml index bb01c11031..49c788c005 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-empty-lines.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-empty-lines.yaml @@ -25,8 +25,9 @@ line: 4 # Cryptic error message is returned when there are two empty lines between metas. # The error message should be more informative and should highlight the exact location # of the error. -message: |- - [4:0] error: extraneous input '\n' expecting {COMMENTARY, 'Q', 'QQ', '*', '$', '[', '(', '@', '^', BYTES, STRING, INT, FLOAT, HEX, NAME, TEXT} +message: | + [4:0] error: 'extraneous input '\n' expecting {COMMENTARY, 'Q', 'QQ', '*', '$', '[', '(', '@', '^', BYTES, STRING, INT, FLOAT, HEX, NAME, TEXT}' + input: | # No comments. [args] > one diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-space-in-meta.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-space-in-meta.yaml index f5bb2547d5..7778e2776a 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-space-in-meta.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/double-space-in-meta.yaml @@ -22,7 +22,7 @@ --- line: 1 message: |- - [1:10] error: Invalid meta declaration: + [1:10] error: 'Invalid meta declaration' +meta with spaces ^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/empty-line-between-metas.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/empty-line-between-metas.yaml index 73f0384a54..0e3cd9dd96 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/empty-line-between-metas.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/empty-line-between-metas.yaml @@ -22,7 +22,7 @@ --- line: 3 message: |- - [3:0] error: Invalid object declaration: + [3:0] error: 'Invalid object declaration' +meta other ^^^^^^^^^^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/missing-empty-line-after-metas.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/missing-empty-line-after-metas.yaml index 44ca6879e9..51da52a793 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/missing-empty-line-after-metas.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/missing-empty-line-after-metas.yaml @@ -22,7 +22,7 @@ --- line: 3 message: |- - [3:0] error: Invalid meta declaration: + [3:0] error: 'Invalid meta declaration' [] > main ^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/not-empty-atoms.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/not-empty-atoms.yaml index db8dd4a130..1dc5a41adf 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/not-empty-atoms.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/not-empty-atoms.yaml @@ -22,7 +22,7 @@ --- line: 4 message: |- - [4:-1] error: Invalid program declaration: + [4:-1] error: 'Invalid program declaration' [] > inner ^^^^^^^^^^^^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application-named.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application-named.yaml index 410ff63447..c39d735c6c 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application-named.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application-named.yaml @@ -22,7 +22,7 @@ --- line: 3 message: |- - [3:-1] error: Invalid program declaration: + [3:-1] error: 'Invalid program declaration' EOF ^^^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application.yaml index f7c3882170..19c8ed8c72 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/redundant-parentheses/simple-application.yaml @@ -27,7 +27,7 @@ line: 3 # place in the input where the error occurred. Moreover it should be clear # what to do to fix the error. 'simple-application-named.yaml' has the same issue. message: |- - [3:-1] error: Invalid program declaration: + [3:-1] error: 'Invalid program declaration' EOF ^^^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/two-spaces.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/two-spaces.yaml index 7c1dbb50ab..f6ceb95e1a 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/two-spaces.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/two-spaces.yaml @@ -22,7 +22,7 @@ --- line: 5 message: >- - [5:2] error: Invalid object declaration: + [5:2] error: 'Invalid object declaration' * ^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-happlication.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-happlication.yaml index fcd162a8a6..5511460fc4 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-happlication.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-happlication.yaml @@ -22,7 +22,7 @@ --- line: 2 message: |- - [2:0] error: Invalid program declaration: + [2:0] error: 'Invalid program declaration' .z ^ input: | diff --git a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-hmethod.yaml b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-hmethod.yaml index d76fb3a8b8..8dfac16a58 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-hmethod.yaml +++ b/eo-parser/src/test/resources/org/eolang/parser/eo-typos/vmethod-after-hmethod.yaml @@ -22,7 +22,7 @@ --- line: 2 message: |- - [2:0] error: Invalid program declaration: + [2:0] error: 'Invalid program declaration' .z ^ input: |