aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/test.lua b/tests/test.lua
index 0434a38..a4ebafe 100755
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -138,22 +138,28 @@ local encode_error_tests = {
138 { json.encode, { function () end }, 138 { json.encode, { function () end },
139 false, { "Cannot serialise function: type not supported" } }, 139 false, { "Cannot serialise function: type not supported" } },
140 function () 140 function ()
141 json.refuse_invalid_numbers("encode") 141 json.encode_invalid_numbers(false)
142 return 'Setting refuse_invalid_numbers("encode")' 142 return 'Setting encode_invalid_numbers(false)'
143 end, 143 end,
144 { json.encode, { NaN }, 144 { json.encode, { NaN },
145 false, { "Cannot serialise number: must not be NaN or Inf" } }, 145 false, { "Cannot serialise number: must not be NaN or Inf" } },
146 { json.encode, { Inf }, 146 { json.encode, { Inf },
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.encode_invalid_numbers("null")
150 return 'Setting refuse_invalid_numbers(false).' 150 return 'Setting encode_invalid_numbers("null").'
151 end,
152 { json.encode, { NaN }, true, { "null" } },
153 { json.encode, { Inf }, true, { "null" } },
154 function ()
155 json.encode_invalid_numbers(true)
156 return 'Setting encode_invalid_numbers(true).'
151 end, 157 end,
152 { json.encode, { NaN }, true, { "nan" } }, 158 { json.encode, { NaN }, true, { "nan" } },
153 { json.encode, { Inf }, true, { "inf" } }, 159 { json.encode, { Inf }, true, { "inf" } },
154 function () 160 function ()
155 json.refuse_invalid_numbers("encode") 161 json.encode_invalid_numbers(false)
156 return 'Setting refuse_invalid_numbers("encode")' 162 return 'Setting encode_invalid_numbers(false)'
157 end, 163 end,
158} 164}
159 165
@@ -233,7 +239,8 @@ util.run_test_group("encode error", encode_error_tests)
233util.run_test_group("escape", escape_tests) 239util.run_test_group("escape", escape_tests)
234util.run_test_group("locale", locale_tests) 240util.run_test_group("locale", locale_tests)
235 241
236json.refuse_invalid_numbers(false) 242json.encode_invalid_numbers(true)
243json.decode_invalid_numbers(true)
237json.encode_max_depth(20) 244json.encode_max_depth(20)
238for i = 1, #arg do 245for i = 1, #arg do
239 util.run_test("decode cycle " .. arg[i], test_decode_cycle, { arg[i] }, 246 util.run_test("decode cycle " .. arg[i], test_decode_cycle, { arg[i] },