Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sjsonnet/src/sjsonnet/stdlib/TypeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,14 @@ object TypeModule extends AbstractFunctionModule {
def evalRhs(v1: Eval, v2: Eval, ev: EvalScope, pos: Position): Val = {
val a = v1.value
val b = v2.value
// Use structural equality first (avoids double materialization on success path)
// Use structural equality first (avoids double materialization on success path).
if (ev.equal(a, b)) Val.True(pos)
else {
// Only materialize on failure for the error message
val x1 = Materializer(a)(ev)
val x2 = Materializer(b)(ev)
Error.fail("std.assertEqual: " + x1 + " != " + x2)
// Match official std.jsonnet: strings are JSON-escaped, and non-strings are
// stringified through Jsonnet value rendering by the later concatenation.
val x1 = Materializer.stringify(a)(ev)
val x2 = Materializer.stringify(b)(ev)
Error.fail("Assertion failed. " + x1 + " != " + x2)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sjsonnet.Error: [std.assertEqual] {"x":1} != {"x":2}
sjsonnet.Error: [std.assertEqual] Assertion failed. {"x": 1} != {"x": 2}
at [<root>].(assert_equal4.jsonnet:1:16)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sjsonnet.Error: [std.assertEqual] "\n " != "\n"
sjsonnet.Error: [std.assertEqual] Assertion failed. "\n " != "\n"
at [<root>].(assert_equal5.jsonnet:1:16)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sjsonnet.Error: [std.assertEqual] "\u001b[31m" != ""
sjsonnet.Error: [std.assertEqual] Assertion failed. "\u001b[31m" != ""
at [<root>].(assert_equal6.jsonnet:1:16)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std.assertEqual({x: 1}, {x: 2})
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sjsonnet.Error: [std.assertEqual] Assertion failed. {"x": 1} != {"x": 2}
at [<root>].(error.assert_equal_official_message.jsonnet:1:16)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sjsonnet.Error: [std.assertEqual] {"a":1} != {"b":1}
sjsonnet.Error: [std.assertEqual] Assertion failed. {"a": 1} != {"b": 1}
at [<root>].(error.assert_equal_obj.jsonnet:17:16)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sjsonnet.Error: [std.assertEqual] "one\ntwo" != "three\nfour\n"
sjsonnet.Error: [std.assertEqual] Assertion failed. "one\ntwo" != "three\nfour\n"
at [<root>].(error.assert_equal_str.jsonnet:17:16)
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sjsonnet.Error: [std.assertEqual] 1 != 2
sjsonnet.Error: [std.assertEqual] Assertion failed. 1 != 2
at [<root>].(error.sanity.jsonnet:17:16)
Loading