Skip to content

Commit

Permalink
Refine file path in syntax error of parser_test.go (#139)
Browse files Browse the repository at this point in the history
* Fix format of (*Error).Error()

* Make FilePath full path in parser_test.go
  • Loading branch information
apstndb authored Oct 17, 2024
1 parent 7062a1b commit 48e607c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (e *Error) String() string {

func (e *Error) Error() string {
var message bytes.Buffer
fmt.Fprintf(&message, "syntax error:%s: %s\n", e.Position, e.Message)
fmt.Fprintf(&message, "syntax error: %s: %s\n", e.Position, e.Message)
if e.Position.Source != "" {
fmt.Fprintln(&message)
fmt.Fprint(&message, e.Position.Source)
Expand Down
5 changes: 3 additions & 2 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ func testParser(t *testing.T, inputPath, resultPath string, parse func(p *memefi
t.Run(in.Name(), func(t *testing.T) {
t.Parallel()

b, err := os.ReadFile(filepath.Join(inputPath, in.Name()))
inputFilePath := filepath.Join(inputPath, in.Name())
b, err := os.ReadFile(inputFilePath)
if err != nil {
t.Fatalf("error on reading input file: %v", err)
}

p := &memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: in.Name(), Buffer: string(b)},
File: &token.File{FilePath: inputFilePath, Buffer: string(b)},
},
}

Expand Down

0 comments on commit 48e607c

Please sign in to comment.