Mercurial > prosody-hg
comparison 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 |
| parents | 3db09eb4c43b |
| children | ee94ac51b2dd |
comparison
equal
deleted
inserted
replaced
| 12032:3db09eb4c43b | 12033:161f8268c4b3 |
|---|---|
| 23 | 23 |
| 24 it("escapes invalid UTF-8", function () | 24 it("escapes invalid UTF-8", function () |
| 25 assert.equal("\"Hello w\\195rld\"", format("%s", "Hello w\195rld")); | 25 assert.equal("\"Hello w\\195rld\"", format("%s", "Hello w\195rld")); |
| 26 end); | 26 end); |
| 27 | 27 |
| 28 if _VERSION >= "Lua 5.4" then | |
| 29 it("handles %p formats", function () | |
| 30 assert.matches("a 0x%x+ b", format("%s %p %s", "a", {}, "b")); | |
| 31 end) | |
| 32 else | |
| 33 it("does something with %p formats", function () | |
| 34 assert.string(format("%p", {})); | |
| 35 end) | |
| 36 end | |
| 28 end); | 37 end); |
| 29 end); | 38 end); |
