# HG changeset patch # User Kim Alvefur # Date 1624976311 -7200 # Node ID fc1b8fe94d047fe3ff62727e0417766339f46fef # Parent f534eeee1552a000e49482b5315b823ea3490a22 util.format: Change formatting of nil values to avoid looking like XML diff -r f534eeee1552 -r fc1b8fe94d04 spec/util_format_spec.lua --- a/spec/util_format_spec.lua Tue Jun 29 16:07:57 2021 +0200 +++ b/spec/util_format_spec.lua Tue Jun 29 16:18:31 2021 +0200 @@ -4,10 +4,10 @@ describe("#format()", function() it("should work", function() assert.equal("hello", format("%s", "hello")); - assert.equal("", format("%s")); - assert.equal("", format("%d")); - assert.equal("", format("%q")); - assert.equal(" []", format("", nil)); + assert.equal("(nil)", format("%s")); + assert.equal("(nil)", format("%d")); + assert.equal("(nil)", format("%q")); + assert.equal(" [(nil)]", format("", nil)); assert.equal("true", format("%s", true)); assert.equal("[true]", format("%d", true)); assert.equal("% [true]", format("%%", true)); diff -r f534eeee1552 -r fc1b8fe94d04 util/format.lua --- a/util/format.lua Tue Jun 29 16:07:57 2021 +0200 +++ b/util/format.lua Tue Jun 29 16:18:31 2021 +0200 @@ -55,7 +55,7 @@ local option = spec:sub(-1); if arg == nil then args[i] = "nil"; - spec = "<%s>"; + spec = "(%s)"; elseif option == "q" then args[i] = dump(arg); spec = "%s"; @@ -77,7 +77,7 @@ i = i + 1; local arg = args[i]; if arg == nil then - args[i] = ""; + args[i] = "(nil)"; else args[i] = tostring(arg); end