diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-05-16 00:08:00 +0930 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-05-16 00:08:00 +0930 |
commit | 2cb7a17e3e5a0bab761661e193ffbea146dade73 (patch) | |
tree | 0da314b86023464d9e68070869004e8851cffb5f | |
parent | 35e81a9c4143890771553c38dce0719630b37517 (diff) | |
download | lua-cjson-2cb7a17e3e5a0bab761661e193ffbea146dade73.tar.gz lua-cjson-2cb7a17e3e5a0bab761661e193ffbea146dade73.tar.bz2 lua-cjson-2cb7a17e3e5a0bab761661e193ffbea146dade73.zip |
Warn that a failed NaN test may not be an error
Sprintf returns "-nan" rather than "nan" on some platforms, which causes
the test script to incorrectly flag a failure.
Also allow test functions without "==> Config" output.
-rw-r--r-- | tests/common.lua | 4 | ||||
-rwxr-xr-x | tests/test.lua | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/tests/common.lua b/tests/common.lua index 156f882..47e3f56 100644 --- a/tests/common.lua +++ b/tests/common.lua | |||
@@ -231,7 +231,9 @@ end | |||
231 | function run_test_group(testgroup, tests) | 231 | function run_test_group(testgroup, tests) |
232 | local function run_config(configname, func) | 232 | local function run_config(configname, func) |
233 | local success, msg = pcall(func) | 233 | local success, msg = pcall(func) |
234 | print(string.format("==> Config %s: %s", configname, msg)) | 234 | if msg then |
235 | print(string.format("==> Config %s: %s", configname, msg)) | ||
236 | end | ||
235 | print() | 237 | print() |
236 | end | 238 | end |
237 | 239 | ||
diff --git a/tests/test.lua b/tests/test.lua index bfa4f66..19f5eca 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -147,9 +147,13 @@ local encode_error_tests = { | |||
147 | false, { "Cannot serialise number: must not be NaN or Inf" } }, | 147 | false, { "Cannot serialise number: must not be NaN or Inf" } }, |
148 | function () | 148 | function () |
149 | json.refuse_invalid_numbers(false) | 149 | json.refuse_invalid_numbers(false) |
150 | return 'Setting refuse_invalid_numbers(false)' | 150 | return 'Setting refuse_invalid_numbers(false).' |
151 | end, | 151 | end, |
152 | { json.encode, { NaN }, true, { "-nan" } }, | 152 | function () |
153 | print('NOTE: receiving "-nan" is ok..') | ||
154 | return | ||
155 | end, | ||
156 | { json.encode, { NaN }, true, { "nan" } }, | ||
153 | { json.encode, { Inf }, true, { "inf" } }, | 157 | { json.encode, { Inf }, true, { "inf" } }, |
154 | function () | 158 | function () |
155 | json.refuse_invalid_numbers("encode") | 159 | json.refuse_invalid_numbers("encode") |