From d007771f8da390816640fa3839b29dcbaa5862d2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 28 Nov 2018 20:36:53 +0100 Subject: util.format: Tweak how nil values are handled Because [] seems exsessive --- spec/util_format_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'spec/util_format_spec.lua') diff --git a/spec/util_format_spec.lua b/spec/util_format_spec.lua index 7e6a0c6e..8a2e9312 100644 --- a/spec/util_format_spec.lua +++ b/spec/util_format_spec.lua @@ -5,6 +5,8 @@ describe("util.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("true", format("%s", true)); assert.equal("[true]", format("%d", true)); -- cgit v1.2.3 From 177420df39c60de47eb47bc5ed574e2ccf082ec4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 12 Oct 2018 01:29:34 +0200 Subject: util.format: Serialize values for the %q format Improves eg debug logs --- spec/util_format_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'spec/util_format_spec.lua') diff --git a/spec/util_format_spec.lua b/spec/util_format_spec.lua index 8a2e9312..b9652d19 100644 --- a/spec/util_format_spec.lua +++ b/spec/util_format_spec.lua @@ -11,6 +11,7 @@ describe("util.format", function() assert.equal("true", format("%s", true)); assert.equal("[true]", format("%d", true)); assert.equal("% [true]", format("%%", true)); + assert.equal("{ }", format("%q", { })); end); end); end); -- cgit v1.2.3 From 236abc4afed5321e0da406e369a8b23dac6fef83 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 30 May 2019 13:41:05 +0200 Subject: util.format: Handle formats expecting an integer in Lua 5.3+ (fixes #1371) --- spec/util_format_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'spec/util_format_spec.lua') diff --git a/spec/util_format_spec.lua b/spec/util_format_spec.lua index b9652d19..82b70205 100644 --- a/spec/util_format_spec.lua +++ b/spec/util_format_spec.lua @@ -12,6 +12,7 @@ describe("util.format", function() assert.equal("[true]", format("%d", true)); assert.equal("% [true]", format("%%", true)); assert.equal("{ }", format("%q", { })); + assert.equal("[1.5]", format("%d", 1.5)); end); end); end); -- cgit v1.2.3 From 2661a6f5a32731100287df9564c45cbe2406e0f0 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 30 May 2019 13:54:11 +0200 Subject: util.format: Handle integer formats the same way on Lua versions without integer support --- spec/util_format_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'spec/util_format_spec.lua') diff --git a/spec/util_format_spec.lua b/spec/util_format_spec.lua index 82b70205..50509630 100644 --- a/spec/util_format_spec.lua +++ b/spec/util_format_spec.lua @@ -13,6 +13,7 @@ describe("util.format", function() assert.equal("% [true]", format("%%", true)); assert.equal("{ }", format("%q", { })); assert.equal("[1.5]", format("%d", 1.5)); + assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464)); end); end); end); -- cgit v1.2.3