Annotate

spec/util_format_spec.lua @ 12721:7830db3c38c3

mod_saslauth: Fix incorrect variable name introduced in 27a4a7e64831
author Matthew Wild <mwild1@gmail.com>
date Sat, 03 Sep 2022 21:25:51 +0100
parent 12571:c4337ff4f1c4
child 12985:c0e3e0d79574
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8383
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local format = require "util.format".format;
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
2 -- There are eight basic types in Lua:
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
3 -- nil, boolean, number, string, function, userdata, thread, and table
8383
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 describe("util.format", function()
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 describe("#format()", function()
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 it("should work", function()
8619
b96b0141cb61 util.format: Fix tests to have expected value first
Kim Alvefur <zash@zash.se>
parents: 8383
diff changeset
8 assert.equal("hello", format("%s", "hello"));
11644
fc1b8fe94d04 util.format: Change formatting of nil values to avoid looking like XML
Kim Alvefur <zash@zash.se>
parents: 11638
diff changeset
9 assert.equal("(nil)", format("%s"));
fc1b8fe94d04 util.format: Change formatting of nil values to avoid looking like XML
Kim Alvefur <zash@zash.se>
parents: 11638
diff changeset
10 assert.equal("(nil)", format("%d"));
fc1b8fe94d04 util.format: Change formatting of nil values to avoid looking like XML
Kim Alvefur <zash@zash.se>
parents: 11638
diff changeset
11 assert.equal("(nil)", format("%q"));
fc1b8fe94d04 util.format: Change formatting of nil values to avoid looking like XML
Kim Alvefur <zash@zash.se>
parents: 11638
diff changeset
12 assert.equal(" [(nil)]", format("", nil));
8619
b96b0141cb61 util.format: Fix tests to have expected value first
Kim Alvefur <zash@zash.se>
parents: 8383
diff changeset
13 assert.equal("true", format("%s", true));
b96b0141cb61 util.format: Fix tests to have expected value first
Kim Alvefur <zash@zash.se>
parents: 8383
diff changeset
14 assert.equal("[true]", format("%d", true));
b96b0141cb61 util.format: Fix tests to have expected value first
Kim Alvefur <zash@zash.se>
parents: 8383
diff changeset
15 assert.equal("% [true]", format("%%", true));
9693
6ed0d6224d64 util.format: Serialize values for the %q format
Kim Alvefur <zash@zash.se>
parents: 9656
diff changeset
16 assert.equal("{ }", format("%q", { }));
10034
4fca92d60040 util.format: Handle formats expecting an integer in Lua 5.3+ (fixes #1371)
Kim Alvefur <zash@zash.se>
parents: 9693
diff changeset
17 assert.equal("[1.5]", format("%d", 1.5));
10035
386f085820e6 util.format: Handle integer formats the same way on Lua versions without integer support
Kim Alvefur <zash@zash.se>
parents: 10034
diff changeset
18 assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464));
8383
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 end);
11638
5f4a657136bc util.format: Escape ASCII control characters in output
Kim Alvefur <zash@zash.se>
parents: 10035
diff changeset
20
5f4a657136bc util.format: Escape ASCII control characters in output
Kim Alvefur <zash@zash.se>
parents: 10035
diff changeset
21 it("escapes ascii control stuff", function ()
5f4a657136bc util.format: Escape ASCII control characters in output
Kim Alvefur <zash@zash.se>
parents: 10035
diff changeset
22 assert.equal("␁", format("%s", "\1"));
12032
3db09eb4c43b util.format: Ensure sanitation of strings passed to wrong format
Kim Alvefur <zash@zash.se>
parents: 12031
diff changeset
23 assert.equal("[␁]", format("%d", "\1"));
11638
5f4a657136bc util.format: Escape ASCII control characters in output
Kim Alvefur <zash@zash.se>
parents: 10035
diff changeset
24 end);
5f4a657136bc util.format: Escape ASCII control characters in output
Kim Alvefur <zash@zash.se>
parents: 10035
diff changeset
25
12031
87bc26f23d9b util.format: Escape invalid UTF-8 by passing trough serialization
Kim Alvefur <zash@zash.se>
parents: 11644
diff changeset
26 it("escapes invalid UTF-8", function ()
87bc26f23d9b util.format: Escape invalid UTF-8 by passing trough serialization
Kim Alvefur <zash@zash.se>
parents: 11644
diff changeset
27 assert.equal("\"Hello w\\195rld\"", format("%s", "Hello w\195rld"));
87bc26f23d9b util.format: Escape invalid UTF-8 by passing trough serialization
Kim Alvefur <zash@zash.se>
parents: 11644
diff changeset
28 end);
87bc26f23d9b util.format: Escape invalid UTF-8 by passing trough serialization
Kim Alvefur <zash@zash.se>
parents: 11644
diff changeset
29
12033
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
30 if _VERSION >= "Lua 5.4" then
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
31 it("handles %p formats", function ()
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
32 assert.matches("a 0x%x+ b", format("%s %p %s", "a", {}, "b"));
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
33 end)
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
34 else
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
35 it("does something with %p formats", function ()
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
36 assert.string(format("%p", {}));
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
37 end)
161f8268c4b3 util.format: Also handle the %p format added in Lua 5.4
Kim Alvefur <zash@zash.se>
parents: 12032
diff changeset
38 end
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
39
12220
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
40 it("escapes multi-line strings", function ()
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
41 assert.equal("Hello\n\tWorld", format("%s", "Hello\nWorld"))
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
42 assert.equal("\"Hello\\nWorld\"", format("%q", "Hello\nWorld"))
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
43 end)
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
44
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
45 -- Tests generated with loops!
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
46 describe("nil", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
47 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
48 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
49 assert.equal("(nil)", format("%c", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
50 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
51 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
52
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
53 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
54 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
55 assert.equal("(nil)", format("%d", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
56 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
57 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
58
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
59 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
60 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
61 assert.equal("(nil)", format("%i", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
62 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
63 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
64
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
65 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
66 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
67 assert.equal("(nil)", format("%o", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
68 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
69 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
70
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
71 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
72 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
73 assert.equal("(nil)", format("%u", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
74 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
75 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
76
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
77 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
78 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
79 assert.equal("(nil)", format("%x", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
80 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
81 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
82
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
83 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
84 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
85 assert.equal("(nil)", format("%X", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
86 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
87 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
88
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
89 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
90 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
91 assert.equal("(nil)", format("%a", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
92 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
93 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
94
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
95 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
96 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
97 assert.equal("(nil)", format("%A", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
98 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
99 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
100
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
101 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
102 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
103 assert.equal("(nil)", format("%e", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
104 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
105 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
106
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
107 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
108 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
109 assert.equal("(nil)", format("%E", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
110 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
111 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
112
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
113 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
114 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
115 assert.equal("(nil)", format("%f", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
116 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
117 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
118
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
119 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
120 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
121 assert.equal("(nil)", format("%g", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
122 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
123 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
124
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
125 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
126 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
127 assert.equal("(nil)", format("%G", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
128 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
129 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
130
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
131 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
132 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
133 assert.equal("(nil)", format("%q", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
134 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
135 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
136
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
137 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
138 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
139 assert.equal("(nil)", format("%s", nil))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
140 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
141 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
142
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
143 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
144
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
145 describe("boolean", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
146 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
147 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
148 assert.equal("[true]", format("%c", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
149 assert.equal("[false]", format("%c", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
150 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
151 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
152
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
153 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
154 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
155 assert.equal("[true]", format("%d", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
156 assert.equal("[false]", format("%d", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
157 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
158 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
159
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
160 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
161 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
162 assert.equal("[true]", format("%i", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
163 assert.equal("[false]", format("%i", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
164 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
165 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
166
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
167 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
168 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
169 assert.equal("[true]", format("%o", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
170 assert.equal("[false]", format("%o", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
171 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
172 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
173
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
174 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
175 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
176 assert.equal("[true]", format("%u", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
177 assert.equal("[false]", format("%u", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
178 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
179 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
180
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
181 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
182 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
183 assert.equal("[true]", format("%x", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
184 assert.equal("[false]", format("%x", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
185 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
186 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
187
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
188 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
189 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
190 assert.equal("[true]", format("%X", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
191 assert.equal("[false]", format("%X", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
192 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
193 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
194
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
195 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
196 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
197 assert.equal("[true]", format("%a", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
198 assert.equal("[false]", format("%a", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
199 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
200 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
201
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
202 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
203 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
204 assert.equal("[true]", format("%A", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
205 assert.equal("[false]", format("%A", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
206 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
207 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
208
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
209 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
210 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
211 assert.equal("[true]", format("%e", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
212 assert.equal("[false]", format("%e", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
213 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
214 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
215
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
216 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
217 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
218 assert.equal("[true]", format("%E", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
219 assert.equal("[false]", format("%E", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
220 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
221 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
222
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
223 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
224 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
225 assert.equal("[true]", format("%f", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
226 assert.equal("[false]", format("%f", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
227 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
228 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
229
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
230 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
231 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
232 assert.equal("[true]", format("%g", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
233 assert.equal("[false]", format("%g", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
234 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
235 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
236
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
237 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
238 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
239 assert.equal("[true]", format("%G", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
240 assert.equal("[false]", format("%G", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
241 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
242 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
243
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
244 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
245 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
246 assert.equal("true", format("%q", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
247 assert.equal("false", format("%q", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
248 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
249 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
250
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
251 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
252 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
253 assert.equal("true", format("%s", true))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
254 assert.equal("false", format("%s", false))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
255 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
256 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
257
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
258 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
259
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
260 describe("number", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
261 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
262 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
263 assert.equal("a", format("%c", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
264 assert.equal("[1.5]", format("%c", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
265 assert.equal("[7.3786976294838e+19]", format("%c", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
266 assert.equal("[inf]", format("%c", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
267 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
268 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
269
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
270 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
271 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
272 assert.equal("97", format("%d", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
273 assert.equal("-12345", format("%d", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
274 assert.equal("[1.5]", format("%d", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
275 assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
276 assert.equal("[inf]", format("%d", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
277 assert.equal("2147483647", format("%d", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
278 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
279 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
280
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
281 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
282 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
283 assert.equal("97", format("%i", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
284 assert.equal("-12345", format("%i", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
285 assert.equal("[1.5]", format("%i", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
286 assert.equal("[7.3786976294838e+19]", format("%i", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
287 assert.equal("[inf]", format("%i", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
288 assert.equal("2147483647", format("%i", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
289 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
290 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
291
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
292 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
293 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
294 assert.equal("141", format("%o", 97))
12036
2ce06f788093 util.format: Fix some formats expecting positive numbers in Lua 5.2
Kim Alvefur <zash@zash.se>
parents: 12034
diff changeset
295 assert.equal("[-12345]", format("%o", -12345))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
296 assert.equal("[1.5]", format("%o", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
297 assert.equal("[7.3786976294838e+19]", format("%o", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
298 assert.equal("[inf]", format("%o", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
299 assert.equal("17777777777", format("%o", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
300 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
301 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
302
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
303 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
304 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
305 assert.equal("97", format("%u", 97))
12036
2ce06f788093 util.format: Fix some formats expecting positive numbers in Lua 5.2
Kim Alvefur <zash@zash.se>
parents: 12034
diff changeset
306 assert.equal("[-12345]", format("%u", -12345))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
307 assert.equal("[1.5]", format("%u", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
308 assert.equal("[7.3786976294838e+19]", format("%u", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
309 assert.equal("[inf]", format("%u", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
310 assert.equal("2147483647", format("%u", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
311 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
312 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
313
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
314 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
315 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
316 assert.equal("61", format("%x", 97))
12036
2ce06f788093 util.format: Fix some formats expecting positive numbers in Lua 5.2
Kim Alvefur <zash@zash.se>
parents: 12034
diff changeset
317 assert.equal("[-12345]", format("%x", -12345))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
318 assert.equal("[1.5]", format("%x", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
319 assert.equal("[7.3786976294838e+19]", format("%x", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
320 assert.equal("[inf]", format("%x", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
321 assert.equal("7fffffff", format("%x", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
322 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
323 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
324
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
325 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
326 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
327 assert.equal("61", format("%X", 97))
12036
2ce06f788093 util.format: Fix some formats expecting positive numbers in Lua 5.2
Kim Alvefur <zash@zash.se>
parents: 12034
diff changeset
328 assert.equal("[-12345]", format("%X", -12345))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
329 assert.equal("[1.5]", format("%X", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
330 assert.equal("[7.3786976294838e+19]", format("%X", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
331 assert.equal("[inf]", format("%X", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
332 assert.equal("7FFFFFFF", format("%X", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
333 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
334 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
335
12571
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
336 describe("to %a", function ()
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
337 it("works", function ()
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
338 assert.equal("0x1.84p+6", format("%a", 97))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
339 assert.equal("-0x1.81c8p+13", format("%a", -12345))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
340 assert.equal("0x1.8p+0", format("%a", 1.5))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
341 assert.equal("0x1p+66", format("%a", 73786976294838206464))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
342 assert.equal("inf", format("%a", math.huge))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
343 assert.equal("0x1.fffffffcp+30", format("%a", 2147483647))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
344 end);
12571
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
345 end);
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
346
12571
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
347 describe("to %A", function ()
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
348 it("works", function ()
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
349 assert.equal("0X1.84P+6", format("%A", 97))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
350 assert.equal("-0X1.81C8P+13", format("%A", -12345))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
351 assert.equal("0X1.8P+0", format("%A", 1.5))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
352 assert.equal("0X1P+66", format("%A", 73786976294838206464))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
353 assert.equal("INF", format("%A", math.huge))
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
354 assert.equal("0X1.FFFFFFFCP+30", format("%A", 2147483647))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
355 end);
12571
c4337ff4f1c4 tests: Remove special-casing of Lua 5.1
Kim Alvefur <zash@zash.se>
parents: 12220
diff changeset
356 end);
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
357
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
358 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
359 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
360 assert.equal("9.700000e+01", format("%e", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
361 assert.equal("-1.234500e+04", format("%e", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
362 assert.equal("1.500000e+00", format("%e", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
363 assert.equal("7.378698e+19", format("%e", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
364 assert.equal("inf", format("%e", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
365 assert.equal("2.147484e+09", format("%e", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
366 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
367 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
368
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
369 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
370 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
371 assert.equal("9.700000E+01", format("%E", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
372 assert.equal("-1.234500E+04", format("%E", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
373 assert.equal("1.500000E+00", format("%E", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
374 assert.equal("7.378698E+19", format("%E", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
375 assert.equal("INF", format("%E", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
376 assert.equal("2.147484E+09", format("%E", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
377 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
378 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
379
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
380 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
381 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
382 assert.equal("97.000000", format("%f", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
383 assert.equal("-12345.000000", format("%f", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
384 assert.equal("1.500000", format("%f", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
385 assert.equal("73786976294838206464.000000", format("%f", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
386 assert.equal("inf", format("%f", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
387 assert.equal("2147483647.000000", format("%f", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
388 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
389 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
390
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
391 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
392 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
393 assert.equal("97", format("%g", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
394 assert.equal("-12345", format("%g", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
395 assert.equal("1.5", format("%g", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
396 assert.equal("7.3787e+19", format("%g", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
397 assert.equal("inf", format("%g", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
398 assert.equal("2.14748e+09", format("%g", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
399 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
400 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
401
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
402 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
403 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
404 assert.equal("97", format("%G", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
405 assert.equal("-12345", format("%G", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
406 assert.equal("1.5", format("%G", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
407 assert.equal("7.3787E+19", format("%G", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
408 assert.equal("INF", format("%G", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
409 assert.equal("2.14748E+09", format("%G", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
410 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
411 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
412
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
413 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
414 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
415 assert.equal("97", format("%q", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
416 assert.equal("-12345", format("%q", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
417 assert.equal("1.5", format("%q", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
418 assert.equal("7.37869762948382065e+19", format("%q", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
419 assert.equal("(1/0)", format("%q", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
420 assert.equal("2147483647", format("%q", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
421 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
422 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
423
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
424 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
425 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
426 assert.equal("97", format("%s", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
427 assert.equal("-12345", format("%s", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
428 assert.equal("1.5", format("%s", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
429 assert.equal("7.3786976294838e+19", format("%s", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
430 assert.equal("inf", format("%s", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
431 assert.equal("2147483647", format("%s", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
432 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
433 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
434
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
435 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
436
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
437 describe("string", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
438 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
439 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
440 assert.equal("[hello]", format("%c", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
441 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%c", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
442 assert.equal("[nödåtgärd]", format("%c", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
443 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%c", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
444 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
445 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
446
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
447 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
448 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
449 assert.equal("[hello]", format("%d", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
450 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%d", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
451 assert.equal("[nödåtgärd]", format("%d", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
452 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%d", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
453 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
454 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
455
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
456 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
457 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
458 assert.equal("[hello]", format("%i", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
459 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%i", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
460 assert.equal("[nödåtgärd]", format("%i", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
461 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%i", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
462 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
463 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
464
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
465 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
466 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
467 assert.equal("[hello]", format("%o", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
468 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%o", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
469 assert.equal("[nödåtgärd]", format("%o", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
470 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%o", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
471 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
472 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
473
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
474 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
475 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
476 assert.equal("[hello]", format("%u", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
477 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%u", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
478 assert.equal("[nödåtgärd]", format("%u", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
479 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%u", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
480 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
481 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
482
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
483 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
484 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
485 assert.equal("[hello]", format("%x", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
486 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%x", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
487 assert.equal("[nödåtgärd]", format("%x", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
488 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%x", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
489 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
490 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
491
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
492 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
493 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
494 assert.equal("[hello]", format("%X", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
495 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%X", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
496 assert.equal("[nödåtgärd]", format("%X", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
497 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%X", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
498 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
499 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
500
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
501 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
502 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
503 assert.equal("[hello]", format("%a", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
504 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%a", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
505 assert.equal("[nödåtgärd]", format("%a", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
506 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%a", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
507 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
508 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
509
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
510 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
511 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
512 assert.equal("[hello]", format("%A", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
513 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%A", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
514 assert.equal("[nödåtgärd]", format("%A", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
515 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%A", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
516 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
517 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
518
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
519 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
520 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
521 assert.equal("[hello]", format("%e", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
522 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%e", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
523 assert.equal("[nödåtgärd]", format("%e", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
524 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%e", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
525 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
526 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
527
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
528 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
529 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
530 assert.equal("[hello]", format("%E", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
531 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%E", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
532 assert.equal("[nödåtgärd]", format("%E", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
533 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%E", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
534 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
535 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
536
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
537 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
538 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
539 assert.equal("[hello]", format("%f", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
540 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%f", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
541 assert.equal("[nödåtgärd]", format("%f", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
542 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%f", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
543 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
544 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
545
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
546 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
547 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
548 assert.equal("[hello]", format("%g", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
549 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%g", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
550 assert.equal("[nödåtgärd]", format("%g", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
551 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%g", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
552 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
553 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
554
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
555 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
556 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
557 assert.equal("[hello]", format("%G", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
558 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%G", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
559 assert.equal("[nödåtgärd]", format("%G", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
560 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%G", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
561 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
562 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
563
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
564 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
565 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
566 assert.equal("\"hello\"", format("%q", "hello"))
12220
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
567 assert.equal("\"foo \\001\\002\\003 bar\"", format("%q", "foo \001\002\003 bar"))
25b853e64d83 util.format: Skip control code escaping when doing full serialization
Kim Alvefur <zash@zash.se>
parents: 12039
diff changeset
568 assert.equal("\"n\\195\\182d\\195\\165tg\\195\\164rd\"", format("%q", "n\195\182d\195\165tg\195\164rd"))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
569 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%q", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
570 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
571 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
572
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
573 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
574 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
575 assert.equal("hello", format("%s", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
576 assert.equal("foo \226\144\129\226\144\130\226\144\131 bar", format("%s", "foo \001\002\003 bar"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
577 assert.equal("nödåtgärd", format("%s", "n\195\182d\195\165tg\195\164rd"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
578 assert.equal("\"n\\195\\182d\\195\\165tg\\195\"", format("%s", "n\195\182d\195\165tg\195"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
579 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
580 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
581
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
582 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
583
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
584 describe("function", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
585 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
586 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
587 assert.matches("[function: 0[xX]%x+]", format("%c", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
588 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
589 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
590
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
591 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
592 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
593 assert.matches("[function: 0[xX]%x+]", format("%d", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
594 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
595 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
596
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
597 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
598 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
599 assert.matches("[function: 0[xX]%x+]", format("%i", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
600 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
601 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
602
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
603 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
604 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
605 assert.matches("[function: 0[xX]%x+]", format("%o", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
606 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
607 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
608
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
609 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
610 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
611 assert.matches("[function: 0[xX]%x+]", format("%u", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
612 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
613 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
614
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
615 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
616 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
617 assert.matches("[function: 0[xX]%x+]", format("%x", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
618 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
619 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
620
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
621 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
622 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
623 assert.matches("[function: 0[xX]%x+]", format("%X", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
624 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
625 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
626
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
627 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
628 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
629 assert.matches("[function: 0[xX]%x+]", format("%a", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
630 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
631 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
632
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
633 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
634 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
635 assert.matches("[function: 0[xX]%x+]", format("%A", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
636 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
637 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
638
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
639 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
640 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
641 assert.matches("[function: 0[xX]%x+]", format("%e", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
642 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
643 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
644
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
645 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
646 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
647 assert.matches("[function: 0[xX]%x+]", format("%E", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
648 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
649 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
650
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
651 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
652 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
653 assert.matches("[function: 0[xX]%x+]", format("%f", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
654 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
655 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
656
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
657 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
658 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
659 assert.matches("[function: 0[xX]%x+]", format("%g", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
660 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
661 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
662
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
663 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
664 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
665 assert.matches("[function: 0[xX]%x+]", format("%G", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
666 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
667 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
668
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
669 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
670 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
671 assert.matches('{__type="function",__error="fail"}', format("%q", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
672 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
673 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
674
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
675 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
676 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
677 assert.matches("function: 0[xX]%x+", format("%s", function() end))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
678 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
679 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
680
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
681 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
682
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
683 describe("thread", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
684 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
685 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
686 assert.matches("[thread: 0[xX]%x+]", format("%c", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
687 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
688 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
689
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
690 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
691 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
692 assert.matches("[thread: 0[xX]%x+]", format("%d", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
693 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
694 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
695
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
696 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
697 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
698 assert.matches("[thread: 0[xX]%x+]", format("%i", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
699 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
700 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
701
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
702 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
703 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
704 assert.matches("[thread: 0[xX]%x+]", format("%o", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
705 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
706 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
707
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
708 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
709 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
710 assert.matches("[thread: 0[xX]%x+]", format("%u", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
711 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
712 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
713
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
714 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
715 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
716 assert.matches("[thread: 0[xX]%x+]", format("%x", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
717 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
718 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
719
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
720 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
721 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
722 assert.matches("[thread: 0[xX]%x+]", format("%X", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
723 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
724 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
725
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
726 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
727 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
728 assert.matches("[thread: 0[xX]%x+]", format("%a", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
729 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
730 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
731
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
732 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
733 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
734 assert.matches("[thread: 0[xX]%x+]", format("%A", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
735 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
736 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
737
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
738 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
739 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
740 assert.matches("[thread: 0[xX]%x+]", format("%e", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
741 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
742 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
743
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
744 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
745 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
746 assert.matches("[thread: 0[xX]%x+]", format("%E", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
747 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
748 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
749
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
750 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
751 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
752 assert.matches("[thread: 0[xX]%x+]", format("%f", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
753 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
754 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
755
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
756 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
757 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
758 assert.matches("[thread: 0[xX]%x+]", format("%g", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
759 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
760 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
761
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
762 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
763 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
764 assert.matches("[thread: 0[xX]%x+]", format("%G", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
765 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
766 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
767
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
768 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
769 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
770 assert.matches('{__type="thread",__error="fail"}', format("%q", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
771 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
772 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
773
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
774 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
775 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
776 assert.matches("thread: 0[xX]%x+", format("%s", coroutine.create(function() end)))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
777 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
778 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
779
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
780 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
781
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
782 describe("table", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
783 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
784 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
785 assert.matches("[table: 0[xX]%x+]", format("%c", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
786 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%c", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
787 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
788 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
789
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
790 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
791 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
792 assert.matches("[table: 0[xX]%x+]", format("%d", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
793 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%d", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
794 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
795 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
796
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
797 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
798 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
799 assert.matches("[table: 0[xX]%x+]", format("%i", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
800 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%i", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
801 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
802 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
803
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
804 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
805 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
806 assert.matches("[table: 0[xX]%x+]", format("%o", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
807 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%o", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
808 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
809 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
810
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
811 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
812 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
813 assert.matches("[table: 0[xX]%x+]", format("%u", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
814 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%u", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
815 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
816 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
817
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
818 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
819 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
820 assert.matches("[table: 0[xX]%x+]", format("%x", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
821 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%x", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
822 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
823 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
824
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
825 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
826 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
827 assert.matches("[table: 0[xX]%x+]", format("%X", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
828 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%X", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
829 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
830 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
831
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
832 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
833 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
834 assert.matches("[table: 0[xX]%x+]", format("%a", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
835 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%a", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
836 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
837 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
838
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
839 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
840 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
841 assert.matches("[table: 0[xX]%x+]", format("%A", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
842 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%A", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
843 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
844 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
845
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
846 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
847 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
848 assert.matches("[table: 0[xX]%x+]", format("%e", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
849 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%e", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
850 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
851 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
852
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
853 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
854 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
855 assert.matches("[table: 0[xX]%x+]", format("%E", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
856 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%E", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
857 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
858 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
859
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
860 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
861 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
862 assert.matches("[table: 0[xX]%x+]", format("%f", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
863 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%f", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
864 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
865 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
866
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
867 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
868 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
869 assert.matches("[table: 0[xX]%x+]", format("%g", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
870 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%g", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
871 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
872 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
873
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
874 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
875 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
876 assert.matches("[table: 0[xX]%x+]", format("%G", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
877 assert.equal("[foo \226\144\129\226\144\130\226\144\131 bar]", format("%G", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
878 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
879 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
880
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
881 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
882 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
883 assert.matches("{ }", format("%q", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
884 assert.equal("{ }", format("%q", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
885 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
886 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
887
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
888 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
889 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
890 assert.matches("table: 0[xX]%x+", format("%s", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
891 assert.equal("foo \226\144\129\226\144\130\226\144\131 bar", format("%s", setmetatable({},{__tostring=function ()return "foo \1\2\3 bar"end})))
12034
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
892 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
893 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
894
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
895 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
896
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
897
8383
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
898 end);
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
899 end);