From c757d6e57d957953bb87a31bc77c88836e5f9f06 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 7 Aug 2023 22:41:49 +0200 Subject: [PATCH] Fix json.Error.== not including the byte offset Changelog: fixed --- std/src/std/json.inko | 4 +++- std/test/std/test_json.inko | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/std/src/std/json.inko b/std/src/std/json.inko index 460ed55ee..37e3b8e47 100644 --- a/std/src/std/json.inko +++ b/std/src/std/json.inko @@ -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 } } diff --git a/std/test/std/test_json.inko b/std/test/std/test_json.inko index 9db6e0c53..fb897b2c1 100644 --- a/std/test/std/test_json.inko +++ b/std/test/std/test_json.inko @@ -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 }