tests/model: comments: specs only
This commit is contained in:
1 parent
5f7f6005f6
commit
fe7566cbba
37 files changed
+72
-440
No files matched your search
+4
-11
@@ -1,6 +1,4 @@
|
||||
-- tests/model/_rbx: helpers shared by the model/rbxm and model/rbxmx tests: instance paths (the scheme of the lune dump
|
||||
-- in tools/fixtures/rbxmx.py), our property values in lune's canonical form, a dump comparison, a deep tree comparison,
|
||||
-- and a tree with a value of every type built from scratch.
|
||||
-- tests/model/_rbx: helpers shared by the rbxm and rbxmx tests (instance paths as in tools/fixtures/rbxmx.py's lune dump).
|
||||
local Rbx = require("@rosetta/codecs/model/Rbx")
|
||||
|
||||
local H = {}
|
||||
@@ -17,7 +15,7 @@ local function hex(s: string): string
|
||||
end))
|
||||
end
|
||||
|
||||
-- paths(tree) -> { [path] = instance }, { [instance] = path }: names joined with "/", "#k" for the k-th sibling of a name
|
||||
-- names joined with "/", "#k" for the k-th sibling of a name
|
||||
function H.paths(tree: any): ({ [string]: any }, { [any]: string })
|
||||
local byPath, ofInst = {}, {}
|
||||
local function walk(list: { any }, prefix: string)
|
||||
@@ -54,7 +52,6 @@ local function numbers(t: string, v: any): { number }?
|
||||
return v
|
||||
end
|
||||
|
||||
-- same(ours: Value, want: lune canon, pathOf, propName) -> ok, detail
|
||||
function H.same(v: any, want: any, pathOf: { [any]: string }, pname: string): (boolean, string)
|
||||
local t = if v then v.type else "nil"
|
||||
local x = if v then v.value else nil
|
||||
@@ -101,7 +98,6 @@ function H.same(v: any, want: any, pathOf: { [any]: string }, pname: string): (b
|
||||
return true, ""
|
||||
end
|
||||
|
||||
-- compare(t, tree, dump, label) -> properties compared: every instance / property of a lune dump against our tree
|
||||
function H.compare(t: any, tree: any, dump: any, label: string): number
|
||||
local byPath, pathOf = H.paths(tree)
|
||||
local n = 0
|
||||
@@ -121,7 +117,7 @@ function H.compare(t: any, tree: any, dump: any, label: string): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- the type family a value compares under (a binary file has one string type; XML writes BrickColor as an int)
|
||||
-- a binary file has one string type; XML writes BrickColor as an int
|
||||
local FAMILY: { [string]: string } = {
|
||||
String = "string",
|
||||
BinaryString = "string",
|
||||
@@ -135,7 +131,6 @@ local function family(t: string): string
|
||||
return FAMILY[t] or t
|
||||
end
|
||||
|
||||
-- equal(a, b, pathA, pathB) -> ok, where: values compared deeply (Refs / Content objects by path)
|
||||
local function equal(a: any, b: any, pa: { [any]: string }, pb: { [any]: string }): boolean
|
||||
if type(a) ~= type(b) then
|
||||
return false
|
||||
@@ -161,8 +156,7 @@ local function equal(a: any, b: any, pa: { [any]: string }, pb: { [any]: string
|
||||
return true
|
||||
end
|
||||
|
||||
-- sameTree(t, a, b, label, opts?) -> instances compared: class, name, children and every property (opts.loose:
|
||||
-- string / int families compare as one type, properties only b has are allowed when another instance of the class has them in a; opts.skipRaw: Raw values are not compared)
|
||||
-- opts.loose: string / int families compare as one type; properties only b has are allowed when another instance of the class has them in a
|
||||
function H.sameTree(t: any, a: any, b: any, label: string, opts: any?): number
|
||||
local o = opts or {}
|
||||
local pa = select(2, H.paths(a))
|
||||
@@ -222,7 +216,6 @@ function H.sameTree(t: any, a: any, b: any, label: string, opts: any?): number
|
||||
return n
|
||||
end
|
||||
|
||||
-- everything() -> a model with one value of every type (and several instances per class)
|
||||
function H.everything(): any
|
||||
local tree = Rbx.tree()
|
||||
local root = Rbx.add(tree, Rbx.instance("Model", "Everything"))
|
||||
|
||||
Reference in new issue
Block a user