From 2cb7a17e3e5a0bab761661e193ffbea146dade73 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Mon, 16 May 2011 00:08:00 +0930 Subject: 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. --- tests/common.lua | 4 +++- 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 function run_test_group(testgroup, tests) local function run_config(configname, func) local success, msg = pcall(func) - print(string.format("==> Config %s: %s", configname, msg)) + if msg then + print(string.format("==> Config %s: %s", configname, msg)) + end print() end 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 = { false, { "Cannot serialise number: must not be NaN or Inf" } }, function () json.refuse_invalid_numbers(false) - return 'Setting refuse_invalid_numbers(false)' + return 'Setting refuse_invalid_numbers(false).' end, - { json.encode, { NaN }, true, { "-nan" } }, + function () + print('NOTE: receiving "-nan" is ok..') + return + end, + { json.encode, { NaN }, true, { "nan" } }, { json.encode, { Inf }, true, { "inf" } }, function () json.refuse_invalid_numbers("encode") -- cgit v1.2.3-55-g6feb