Diff

spec/util_format_spec.lua @ 12033:161f8268c4b3

util.format: Also handle the %p format added in Lua 5.4
author Kim Alvefur <zash@zash.se>
date Sat, 11 Dec 2021 13:39:58 +0100
parent 12032:3db09eb4c43b
child 12034:ee94ac51b2dd
line wrap: on
line diff
--- a/spec/util_format_spec.lua	Sat Dec 11 13:30:34 2021 +0100
+++ b/spec/util_format_spec.lua	Sat Dec 11 13:39:58 2021 +0100
@@ -25,5 +25,14 @@
 			assert.equal("\"Hello w\\195rld\"", format("%s", "Hello w\195rld"));
 		end);
 
+		if _VERSION >= "Lua 5.4" then
+			it("handles %p formats", function ()
+				assert.matches("a 0x%x+ b", format("%s %p %s", "a", {}, "b"));
+			end)
+		else
+			it("does something with %p formats", function ()
+				assert.string(format("%p", {}));
+			end)
+		end
 	end);
 end);