Annotate

spec/util_format_spec.lua @ 12491:dc0c20753d6c 0.12

mod_invites_adhoc: Fall back to generic allow_user_invites for role-less users Fixes #1752
author Matthew Wild <mwild1@gmail.com>
date Fri, 06 May 2022 17:08:49 +0100
parent 12220:25b853e64d83
child 12571:c4337ff4f1c4
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
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
336 if _VERSION > "Lua 5.1" then -- COMPAT no %a or %A in Lua 5.1
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
337 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
338 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
339 assert.equal("0x1.84p+6", format("%a", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
340 assert.equal("-0x1.81c8p+13", format("%a", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
341 assert.equal("0x1.8p+0", format("%a", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
342 assert.equal("0x1p+66", format("%a", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
343 assert.equal("inf", format("%a", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
344 assert.equal("0x1.fffffffcp+30", format("%a", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
345 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
346 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
347
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
348 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
349 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
350 assert.equal("0X1.84P+6", format("%A", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
351 assert.equal("-0X1.81C8P+13", format("%A", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
352 assert.equal("0X1.8P+0", format("%A", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
353 assert.equal("0X1P+66", format("%A", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
354 assert.equal("INF", format("%A", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
355 assert.equal("0X1.FFFFFFFCP+30", format("%A", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
356 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
357 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
358 end
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
359
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
360 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
361 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
362 assert.equal("9.700000e+01", format("%e", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
363 assert.equal("-1.234500e+04", format("%e", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
364 assert.equal("1.500000e+00", format("%e", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
365 assert.equal("7.378698e+19", format("%e", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
366 assert.equal("inf", format("%e", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
367 assert.equal("2.147484e+09", format("%e", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
368 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
369 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
370
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
371 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
372 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
373 assert.equal("9.700000E+01", format("%E", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
374 assert.equal("-1.234500E+04", format("%E", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
375 assert.equal("1.500000E+00", format("%E", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
376 assert.equal("7.378698E+19", format("%E", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
377 assert.equal("INF", format("%E", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
378 assert.equal("2.147484E+09", format("%E", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
379 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
380 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
381
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
382 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
383 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
384 assert.equal("97.000000", format("%f", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
385 assert.equal("-12345.000000", format("%f", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
386 assert.equal("1.500000", format("%f", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
387 assert.equal("73786976294838206464.000000", format("%f", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
388 assert.equal("inf", format("%f", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
389 assert.equal("2147483647.000000", format("%f", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
390 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
391 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
392
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
393 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
394 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
395 assert.equal("97", format("%g", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
396 assert.equal("-12345", format("%g", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
397 assert.equal("1.5", format("%g", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
398 assert.equal("7.3787e+19", format("%g", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
399 assert.equal("inf", format("%g", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
400 assert.equal("2.14748e+09", format("%g", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
401 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
402 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
403
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
404 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
405 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
406 assert.equal("97", format("%G", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
407 assert.equal("-12345", format("%G", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
408 assert.equal("1.5", format("%G", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
409 assert.equal("7.3787E+19", format("%G", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
410 assert.equal("INF", format("%G", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
411 assert.equal("2.14748E+09", format("%G", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
412 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
413 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
414
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
415 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
416 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
417 assert.equal("97", format("%q", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
418 assert.equal("-12345", format("%q", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
419 assert.equal("1.5", format("%q", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
420 assert.equal("7.37869762948382065e+19", format("%q", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
421 assert.equal("(1/0)", format("%q", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
422 assert.equal("2147483647", format("%q", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
423 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
424 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
425
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
426 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
427 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
428 assert.equal("97", format("%s", 97))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
429 assert.equal("-12345", format("%s", -12345))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
430 assert.equal("1.5", format("%s", 1.5))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
431 assert.equal("7.3786976294838e+19", format("%s", 73786976294838206464))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
432 assert.equal("inf", format("%s", math.huge))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
433 assert.equal("2147483647", format("%s", 2147483647))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
434 end);
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 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
438
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
439 describe("string", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
440 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
441 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
442 assert.equal("[hello]", format("%c", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
443 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
444 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
445 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
446 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
447 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
448
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
449 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
450 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
451 assert.equal("[hello]", format("%d", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
452 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
453 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
454 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
455 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
456 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
457
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
458 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
459 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
460 assert.equal("[hello]", format("%i", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
461 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
462 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
463 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
464 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
465 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
466
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
467 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
468 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
469 assert.equal("[hello]", format("%o", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
470 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
471 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
472 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
473 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
474 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
475
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
476 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
477 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
478 assert.equal("[hello]", format("%u", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
479 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
480 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
481 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
482 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
483 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
484
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
485 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
486 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
487 assert.equal("[hello]", format("%x", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
488 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
489 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
490 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
491 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
492 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
493
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
494 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
495 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
496 assert.equal("[hello]", format("%X", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
497 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
498 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
499 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
500 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
501 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
502
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
503 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
504 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
505 assert.equal("[hello]", format("%a", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
506 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
507 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
508 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
509 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
510 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
511
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
512 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
513 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
514 assert.equal("[hello]", format("%A", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
515 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
516 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
517 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
518 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
519 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
520
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
521 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
522 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
523 assert.equal("[hello]", format("%e", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
524 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
525 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
526 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
527 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
528 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
529
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
530 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
531 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
532 assert.equal("[hello]", format("%E", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
533 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
534 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
535 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
536 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
537 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
538
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
539 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
540 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
541 assert.equal("[hello]", format("%f", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
542 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
543 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
544 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
545 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
546 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
547
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
548 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
549 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
550 assert.equal("[hello]", format("%g", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
551 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
552 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
553 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
554 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
555 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
556
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
557 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
558 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
559 assert.equal("[hello]", format("%G", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
560 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
561 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
562 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
563 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
564 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
565
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
566 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
567 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
568 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
569 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
570 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
571 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
572 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
573 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
574
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
575 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
576 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
577 assert.equal("hello", format("%s", "hello"))
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
578 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
579 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
580 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
581 end);
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 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
585
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
586 describe("function", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
587 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
588 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
589 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
590 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
591 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
592
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
593 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
594 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
595 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
596 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
597 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
598
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
599 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
600 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
601 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
602 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
603 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
604
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
605 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
606 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
607 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
608 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
609 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
610
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
611 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
612 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
613 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
614 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
615 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
616
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
617 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
618 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
619 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
620 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
621 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
622
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
623 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
624 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
625 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
626 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
627 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
628
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
629 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
630 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
631 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
632 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
633 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
634
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
635 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
636 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
637 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
638 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
639 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
640
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
641 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
642 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
643 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
644 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
645 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
646
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
647 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
648 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
649 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
650 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
651 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
652
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
653 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
654 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
655 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
656 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
657 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
658
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
659 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
660 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
661 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
662 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
663 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
664
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
665 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
666 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
667 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
668 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
669 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
670
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
671 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
672 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
673 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
674 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
675 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
676
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
677 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
678 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
679 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
680 end);
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 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
684
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
685 describe("thread", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
686 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
687 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
688 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
689 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
690 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
691
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
692 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
693 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
694 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
695 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
696 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
697
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
698 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
699 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
700 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
701 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
702 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
703
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
704 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
705 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
706 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
707 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
708 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
709
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
710 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
711 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
712 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
713 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
714 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
715
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
716 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
717 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
718 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
719 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
720 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
721
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
722 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
723 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
724 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
725 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
726 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
727
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
728 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
729 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
730 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
731 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
732 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
733
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
734 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
735 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
736 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
737 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
738 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
739
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
740 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
741 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
742 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
743 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
744 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
745
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
746 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
747 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
748 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
749 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
750 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
751
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
752 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
753 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
754 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
755 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
756 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
757
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
758 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
759 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
760 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
761 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
762 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
763
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
764 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
765 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
766 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
767 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
768 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
769
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
770 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
771 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
772 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
773 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
774 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
775
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
776 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
777 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
778 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
779 end);
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 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
783
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
784 describe("table", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
785 describe("to %c", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
786 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
787 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
788 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
789 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
790 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
791
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
792 describe("to %d", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
793 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
794 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
795 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
796 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
797 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
798
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
799 describe("to %i", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
800 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
801 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
802 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
803 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
804 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
805
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
806 describe("to %o", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
807 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
808 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
809 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
810 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
811 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
812
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
813 describe("to %u", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
814 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
815 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
816 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
817 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
818 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
819
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
820 describe("to %x", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
821 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
822 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
823 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
824 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
825 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
826
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
827 describe("to %X", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
828 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
829 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
830 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
831 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
832 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
833
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
834 describe("to %a", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
835 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
836 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
837 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
838 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
839 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
840
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
841 describe("to %A", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
842 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
843 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
844 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
845 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
846 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
847
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
848 describe("to %e", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
849 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
850 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
851 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
852 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
853 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
854
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
855 describe("to %E", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
856 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
857 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
858 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
859 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
860 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
861
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
862 describe("to %f", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
863 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
864 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
865 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
866 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
867 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
868
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
869 describe("to %g", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
870 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
871 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
872 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
873 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
874 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
875
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
876 describe("to %G", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
877 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
878 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
879 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
880 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
881 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
882
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
883 describe("to %q", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
884 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
885 assert.matches("{ }", format("%q", { }))
12039
e0a8c5b1ab4f util.format: Ensure metatable __tostring results are also sanitized
Kim Alvefur <zash@zash.se>
parents: 12036
diff changeset
886 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
887 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
888 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
889
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
890 describe("to %s", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
891 it("works", function ()
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
892 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
893 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
894 end);
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 end);
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
898
ee94ac51b2dd util.format: ALL THE TESTS!!!
Kim Alvefur <zash@zash.se>
parents: 12033
diff changeset
899
8383
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
900 end);
d967d6f2ad00 util.format: Move tests to spec/
Kim Alvefur <zash@zash.se>
parents:
diff changeset
901 end);