Skip to content

Commit

Permalink
Fix json.Error.== not including the byte offset
Browse files Browse the repository at this point in the history
Changelog: fixed
  • Loading branch information
yorickpeterse committed Aug 7, 2023
1 parent 4297c80 commit c757d6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion std/src/std/json.inko
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ class pub Error {

impl Equal[Error] for Error {
fn pub ==(other: ref Error) -> Bool {
@message == other.message and @line == other.line
@message == other.message
and @line == other.line
and @offset == other.offset
}
}

Expand Down
9 changes: 9 additions & 0 deletions std/test/std/test_json.inko
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ fn pub tests(t: mut Tests) {
t.equal(fmt(err), 'foo, on line 1 at byte offset 5')
}

t.test('Error.==') fn (t) {
let err1 = Error { @message = 'foo', @line = 1, @offset = 5 }
let err2 = Error { @message = 'foo', @line = 1, @offset = 5 }
let err3 = Error { @message = 'foo', @line = 1, @offset = 6 }

t.equal(err1, err2)
t.not_equal(err1, err3)
}

t.test('Error.to_string') fn (t) {
let err = Error { @message = 'foo', @line = 1, @offset = 5 }

Expand Down

0 comments on commit c757d6e

Please sign in to comment.