diff options
Diffstat (limited to 'testes')
-rw-r--r-- | testes/strings.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/testes/strings.lua b/testes/strings.lua index da53a87e..8bcbb391 100644 --- a/testes/strings.lua +++ b/testes/strings.lua | |||
@@ -153,6 +153,22 @@ else -- compatible coercion | |||
153 | assert(tostring(-1203 + 0.0) == "-1203") | 153 | assert(tostring(-1203 + 0.0) == "-1203") |
154 | end | 154 | end |
155 | 155 | ||
156 | do -- tests for '%p' format | ||
157 | -- not much to test, as C does not specify what '%p' does. | ||
158 | -- ("The value of the pointer is converted to a sequence of printing | ||
159 | -- characters, in an implementation-defined manner.") | ||
160 | local null = string.format("%p", nil) | ||
161 | assert(string.format("%p", {}) ~= null) | ||
162 | assert(string.format("%p", 4) == null) | ||
163 | assert(string.format("%p", print) ~= null) | ||
164 | assert(string.format("%p", coroutine.running()) ~= null) | ||
165 | assert(string.format("%p", {}) ~= string.format("%p", {})) | ||
166 | assert(string.format("%p", string.rep("a", 10)) == | ||
167 | string.format("%p", string.rep("a", 10))) -- short strings | ||
168 | assert(string.format("%p", string.rep("a", 300)) ~= | ||
169 | string.format("%p", string.rep("a", 300))) -- long strings | ||
170 | assert(#string.format("%90p", {}) == 90) | ||
171 | end | ||
156 | 172 | ||
157 | x = '"ílo"\n\\' | 173 | x = '"ílo"\n\\' |
158 | assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\') | 174 | assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\') |