Software /
code /
prosody
Comparison
spec/util_format_spec.lua @ 12985:c0e3e0d79574
util.format: Update tests for serialization changes
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 26 Mar 2023 00:49:25 +0100 |
parent | 12571:c4337ff4f1c4 |
comparison
equal
deleted
inserted
replaced
12984:f08125a8be34 | 12985:c0e3e0d79574 |
---|---|
11 assert.equal("(nil)", format("%q")); | 11 assert.equal("(nil)", format("%q")); |
12 assert.equal(" [(nil)]", format("", nil)); | 12 assert.equal(" [(nil)]", format("", nil)); |
13 assert.equal("true", format("%s", true)); | 13 assert.equal("true", format("%s", true)); |
14 assert.equal("[true]", format("%d", true)); | 14 assert.equal("[true]", format("%d", true)); |
15 assert.equal("% [true]", format("%%", true)); | 15 assert.equal("% [true]", format("%%", true)); |
16 assert.equal("{ }", format("%q", { })); | 16 assert.equal("{}", format("%q", {})); |
17 assert.equal("[1.5]", format("%d", 1.5)); | 17 assert.equal("[1.5]", format("%d", 1.5)); |
18 assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464)); | 18 assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464)); |
19 end); | 19 end); |
20 | 20 |
21 it("escapes ascii control stuff", function () | 21 it("escapes ascii control stuff", function () |
666 end); | 666 end); |
667 end); | 667 end); |
668 | 668 |
669 describe("to %q", function () | 669 describe("to %q", function () |
670 it("works", function () | 670 it("works", function () |
671 assert.matches('{__type="function",__error="fail"}', format("%q", function() end)) | 671 assert.matches('%[%[function: 0[xX]%x+]]', format("%q", function() end)) |
672 end); | 672 end); |
673 end); | 673 end); |
674 | 674 |
675 describe("to %s", function () | 675 describe("to %s", function () |
676 it("works", function () | 676 it("works", function () |
765 end); | 765 end); |
766 end); | 766 end); |
767 | 767 |
768 describe("to %q", function () | 768 describe("to %q", function () |
769 it("works", function () | 769 it("works", function () |
770 assert.matches('{__type="thread",__error="fail"}', format("%q", coroutine.create(function() end))) | 770 assert.matches('_%[%[thread: 0[xX]%x+]]', format("%q", coroutine.create(function() end))) |
771 end); | 771 end); |
772 end); | 772 end); |
773 | 773 |
774 describe("to %s", function () | 774 describe("to %s", function () |
775 it("works", function () | 775 it("works", function () |
878 end); | 878 end); |
879 end); | 879 end); |
880 | 880 |
881 describe("to %q", function () | 881 describe("to %q", function () |
882 it("works", function () | 882 it("works", function () |
883 assert.matches("{ }", format("%q", { })) | 883 assert.matches("{}", format("%q", { })) |
884 assert.equal("{ }", format("%q", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end}))) | 884 assert.equal("{}", format("%q", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end}))) |
885 end); | 885 end); |
886 end); | 886 end); |
887 | 887 |
888 describe("to %s", function () | 888 describe("to %s", function () |
889 it("works", function () | 889 it("works", function () |