aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-06-10 22:39:55 -0300
committerGitHub <noreply@github.com>2024-06-11 09:39:55 +0800
commitc92ecda53337490633c95e6ae00e322dc9ad1fb8 (patch)
tree47185f92938547b2c70fcf00b02c9acef772ac9c /tests
parentd20576d5cef3d7aa3b6d62db7aee9d9d5f03cc70 (diff)
downloadlua-cjson-c92ecda53337490633c95e6ae00e322dc9ad1fb8.tar.gz
lua-cjson-c92ecda53337490633c95e6ae00e322dc9ad1fb8.tar.bz2
lua-cjson-c92ecda53337490633c95e6ae00e322dc9ad1fb8.zip
feature: Lua 5.3 + 5.4 integer support, with CI and conflicts fixed.
Co-Authored-By: Hisham Muhammad <hisham@gobolinux.org> Co-authored-by: Mark Pulford <mark@kyne.com.au> Co-authored-by: ichenq <ichenq@gmail.com> Co-authored-by: Cloud Wu <cloudwu@gmail.com> Co-authored-by: caijietao <t0350.prog@gmail.com> Co-authored-by: actboy168 <actboy168@gmail.com> Co-authored-by: wudeng <wudeng256@gmail.com> Co-authored-by: caiyiheng <rangercyh@qq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/agentzh.t42
-rwxr-xr-xtests/genutf8.pl1
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/agentzh.t b/tests/agentzh.t
index 552630a..88a94b8 100644
--- a/tests/agentzh.t
+++ b/tests/agentzh.t
@@ -332,3 +332,45 @@ Cannot serialise function: type not supported
332 332
333{"valid":"valid"} 333{"valid":"valid"}
334["one","two","three"] 334["one","two","three"]
335
336
337
338=== TEST 23: array-like proxy object with __len and __index
339--- lua
340local cjson = require "cjson"
341local real_array = {"foo", "bar", "baz"}
342local proxy_array = {}
343setmetatable(proxy_array, {
344 __len = function() return 3 end,
345 __index = function(t, k)
346 return real_array[k]
347 end,
348})
349
350print(cjson.encode(proxy_array))
351--- out
352["foo","bar","baz"]
353
354
355
356=== TEST 24: check that integers are handled correctly on Lua 5.3+
357--- lua
358local lv = tonumber((_VERSION):match("Lua 5%.([0-9]+)"))
359
360if lv >= 3 then
361 local cjson = require "cjson"
362 local array = cjson.decode [[ [10, 10.0, 3.5] ]]
363 for i = 1, 4 do
364 print(tostring(i) .. ": " .. tostring(math.type(array[i])))
365 end
366else
367 print("1: integer")
368 print("2: float")
369 print("3: float")
370 print("4: nil")
371end
372--- out
3731: integer
3742: float
3753: float
3764: nil
diff --git a/tests/genutf8.pl b/tests/genutf8.pl
index db661a1..c79f238 100755
--- a/tests/genutf8.pl
+++ b/tests/genutf8.pl
@@ -6,6 +6,7 @@
6# cff03b039d850f370a7362f3313e5268 6# cff03b039d850f370a7362f3313e5268
7 7
8use strict; 8use strict;
9no warnings 'nonchar';
9 10
10# 0xD800 - 0xDFFF are used to encode supplementary codepoints 11# 0xD800 - 0xDFFF are used to encode supplementary codepoints
11# 0x10000 - 0x10FFFF are supplementary codepoints 12# 0x10000 - 0x10FFFF are supplementary codepoints