Comparison

spec/util_format_spec.lua @ 11644:fc1b8fe94d04

util.format: Change formatting of nil values to avoid looking like XML
author Kim Alvefur <zash@zash.se>
date Tue, 29 Jun 2021 16:18:31 +0200
parent 11638:5f4a657136bc
child 12031:87bc26f23d9b
comparison
equal deleted inserted replaced
11643:f534eeee1552 11644:fc1b8fe94d04
2 2
3 describe("util.format", function() 3 describe("util.format", function()
4 describe("#format()", function() 4 describe("#format()", function()
5 it("should work", function() 5 it("should work", function()
6 assert.equal("hello", format("%s", "hello")); 6 assert.equal("hello", format("%s", "hello"));
7 assert.equal("<nil>", format("%s")); 7 assert.equal("(nil)", format("%s"));
8 assert.equal("<nil>", format("%d")); 8 assert.equal("(nil)", format("%d"));
9 assert.equal("<nil>", format("%q")); 9 assert.equal("(nil)", format("%q"));
10 assert.equal(" [<nil>]", format("", nil)); 10 assert.equal(" [(nil)]", format("", nil));
11 assert.equal("true", format("%s", true)); 11 assert.equal("true", format("%s", true));
12 assert.equal("[true]", format("%d", true)); 12 assert.equal("[true]", format("%d", true));
13 assert.equal("% [true]", format("%%", true)); 13 assert.equal("% [true]", format("%%", true));
14 assert.equal("{ }", format("%q", { })); 14 assert.equal("{ }", format("%q", { }));
15 assert.equal("[1.5]", format("%d", 1.5)); 15 assert.equal("[1.5]", format("%d", 1.5));