mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Update testkit
This commit is contained in:
parent
15026b5ad3
commit
c0c2166edf
1 changed files with 12 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- testkit.luau
|
-- testkit.luau
|
||||||
-- v0.7.1
|
-- v0.7.2
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local color = {
|
local color = {
|
||||||
|
|
@ -323,7 +323,7 @@ end
|
||||||
|
|
||||||
local function print2(v: unknown)
|
local function print2(v: unknown)
|
||||||
type Buffer = { n: number, [number]: string }
|
type Buffer = { n: number, [number]: string }
|
||||||
type Cyclic = { [{}]: true }
|
type Cyclic = { n: number, [{}]: number }
|
||||||
|
|
||||||
-- overkill concatenationless string buffer
|
-- overkill concatenationless string buffer
|
||||||
local function tos(value: any, stack: number, str: Buffer, cyclic: Cyclic)
|
local function tos(value: any, stack: number, str: Buffer, cyclic: Cyclic)
|
||||||
|
|
@ -347,16 +347,19 @@ local function print2(v: unknown)
|
||||||
else -- is table
|
else -- is table
|
||||||
local tabbed_indent = indent .. TAB
|
local tabbed_indent = indent .. TAB
|
||||||
|
|
||||||
str.n += 1
|
|
||||||
|
|
||||||
if cyclic[value] then
|
if cyclic[value] then
|
||||||
str[str.n] = color.gray "*cyclic reference*"
|
str.n += 1
|
||||||
|
str[str.n] = color.gray(`CYCLIC REF {cyclic[value]}`)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
cyclic[value] = true
|
cyclic.n += 1
|
||||||
|
cyclic[value] = cyclic.n
|
||||||
end
|
end
|
||||||
|
|
||||||
str[str.n] = "{\n"
|
str.n += 3
|
||||||
|
str[str.n - 2] = "{ "
|
||||||
|
str[str.n - 1] = color.gray(tostring(cyclic[value]))
|
||||||
|
str[str.n - 0] = "\n"
|
||||||
|
|
||||||
local i, v = next(value, nil)
|
local i, v = next(value, nil)
|
||||||
while v ~= nil do
|
while v ~= nil do
|
||||||
|
|
@ -393,7 +396,7 @@ local function print2(v: unknown)
|
||||||
end
|
end
|
||||||
|
|
||||||
local str = { n = 0 }
|
local str = { n = 0 }
|
||||||
local cyclic = {}
|
local cyclic = { n = 0 }
|
||||||
tos(v, 0, str, cyclic)
|
tos(v, 0, str, cyclic)
|
||||||
print(table.concat(str))
|
print(table.concat(str))
|
||||||
end
|
end
|
||||||
|
|
@ -455,7 +458,7 @@ return {
|
||||||
return BENCH, START
|
return BENCH, START
|
||||||
end,
|
end,
|
||||||
|
|
||||||
print2 = print2,
|
print = print2,
|
||||||
|
|
||||||
seq = shallow_eq,
|
seq = shallow_eq,
|
||||||
deq = deep_eq,
|
deq = deep_eq,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue