883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
130 lines
7.0 KiB
Lua
130 lines
7.0 KiB
Lua
-- Original C_Item tuple contracts and tooltip display; no actual client/state.
|
|
local originalPrint = print
|
|
local lines, secrets, calls, tooltipCalls, frames = {}, {}, {}, {}, 0
|
|
print = function(...) lines[#lines + 1] = {...} end
|
|
CreateFrame = function()
|
|
frames = frames + 1
|
|
return {RegisterEvent = function() end, SetScript = function() end}
|
|
end
|
|
SlashCmdList = {}
|
|
issecretvalue = function(value) return secrets[value] or false end
|
|
GetItemInfo = function() error('Do not call an assumed global API') end
|
|
GatewayDiagnosticsSaved = {nativeSkillAcceptance = {retained = true}, spellDefinitions = {retained = true}}
|
|
local secret = 'PRIVATE_ITEM_SENTINEL'
|
|
local hidden = setmetatable({}, {__index = function() error('Private table indexed') end,
|
|
__tostring = function() error('Private table stringified') end})
|
|
secrets[secret], secrets[hidden] = true, true
|
|
local function good(id)
|
|
return {name = 'Source-backed item', itemID = id, quality = 4, itemLevel = 60, reqLevel = 55,
|
|
maxStack = 20, sellPrice = 12345, classID = 15, subclassID = 0, inventoryType = 0, icon = 134328}
|
|
end
|
|
local function api(value)
|
|
return {
|
|
GetItemInfo = function(id)
|
|
calls[#calls + 1] = {'info', id}
|
|
if value == nil then return end
|
|
return value.name, secret, value.quality, value.itemLevel, value.reqLevel,
|
|
'Miscellaneous', 'Junk', value.maxStack, '', value.icon, value.sellPrice,
|
|
value.classID, value.subclassID, 0, 0, nil, false, secret
|
|
end,
|
|
GetItemInfoInstant = function(id)
|
|
calls[#calls + 1] = {'instant', id}
|
|
if value == nil then return end
|
|
return value.itemID, 'Miscellaneous', 'Junk', '', value.icon, value.classID, value.subclassID
|
|
end,
|
|
GetItemInventoryTypeByID = function(id)
|
|
calls[#calls + 1] = {'inventory', id}
|
|
return value and value.inventoryType
|
|
end,
|
|
}
|
|
end
|
|
UIParent = {}
|
|
GameTooltip = {}
|
|
for _, method in ipairs({'SetOwner', 'ClearAllPoints', 'SetPoint', 'SetItemByID', 'Show'}) do
|
|
GameTooltip[method] = function(self, ...)
|
|
assert(self == GameTooltip)
|
|
tooltipCalls[#tooltipCalls + 1] = {method, ...}
|
|
end
|
|
end
|
|
local tooltip = GameTooltip
|
|
C_Item = api(good(500001)); local originalAPI = C_Item
|
|
dofile(arg[1] .. '/client_addons/GatewayDiagnostics/GatewayDiagnostics.lua')
|
|
local slash = SlashCmdList.GATEWAYDIAGNOSTICS
|
|
slash('item-info 500001')
|
|
local definitions = GatewayDiagnosticsSaved.itemDefinitions
|
|
local row = definitions[500001]
|
|
for key, value in pairs(good(500001)) do assert(row[key] == value) end
|
|
assert(row.infoStatus == 'ok' and row.instantStatus == 'ok' and row.inventoryStatus == 'ok')
|
|
assert(row.tooltipStatus == 'requested' and #tooltipCalls == 5)
|
|
assert(tooltipCalls[4][1] == 'SetItemByID' and tooltipCalls[4][2] == 500001)
|
|
assert(C_Item == originalAPI and GatewayDiagnosticsSaved.nativeSkillAcceptance.retained)
|
|
assert(GatewayDiagnosticsSaved.spellDefinitions.retained)
|
|
local before, beforeTooltip = #calls, #tooltipCalls
|
|
for _, command in ipairs({'item-info', 'item-info 0', 'item-info -1', 'item-info 1.5',
|
|
'item-info 2147483648', 'item-info x', 'item-info 1 extra', 'item-info 1e3'}) do
|
|
slash(command)
|
|
assert(#calls == before and #tooltipCalls == beforeTooltip and definitions[500001] == row)
|
|
end
|
|
local cases = {
|
|
{api = nil, status = 'unsupported'},
|
|
{api = {}, status = 'unsupported'},
|
|
{api = api(nil), status = 'nil'},
|
|
{api = setmetatable({}, {__index = function() error(secret) end}), status = 'failed'},
|
|
{api = {
|
|
GetItemInfo = function() error(secret) end,
|
|
GetItemInfoInstant = function() error(secret) end,
|
|
GetItemInventoryTypeByID = function() error(secret) end,
|
|
}, status = 'failed'},
|
|
}
|
|
for _, case in ipairs(cases) do
|
|
C_Item = case.api; slash('item-info 500001'); row = definitions[500001]
|
|
assert(row.infoStatus == case.status and row.instantStatus == case.status and row.inventoryStatus == case.status)
|
|
assert(row.name == nil and row.itemID == nil and row.inventoryType == nil)
|
|
end
|
|
for _, value in ipairs({secret, hidden, math.huge, 0/0, -1, true, '60', 1.5}) do
|
|
local bad = good(500001); bad.itemLevel = value
|
|
C_Item = api(bad); slash('item-info 500001'); row = definitions[500001]
|
|
assert(row.infoStatus == 'not-public' and row.itemLevel == nil and row.name == nil)
|
|
assert(row.instantStatus == 'ok' and row.itemID == 500001)
|
|
end
|
|
local bad = good(500001); bad.name, bad.itemID, bad.inventoryType = secret, secret, hidden
|
|
C_Item = api(bad); slash('item-info 500001'); row = definitions[500001]
|
|
assert(row.infoStatus == 'not-public' and row.instantStatus == 'not-public' and row.inventoryStatus == 'not-public')
|
|
bad = good(500002); C_Item = api(bad); slash('item-info 500001')
|
|
assert(definitions[500001].instantStatus == 'identity-mismatch' and definitions[500001].itemID == nil)
|
|
C_Item = api(good(500001)); C_Item.GetItemInfo = function() return nil end
|
|
slash('item-info 500001'); row = definitions[500001]
|
|
assert(row.infoStatus == 'nil' and row.instantStatus == 'ok' and row.itemID == 500001 and row.name == nil)
|
|
C_Item = api(good(500001)); C_Item.GetItemInfoInstant = function() return 500001, '', '', '', 133042, 2, 4 end
|
|
slash('item-info 500001'); row = definitions[500001]
|
|
assert(row.infoStatus == 'ok' and row.instantStatus == 'identity-mismatch' and row.itemID == nil)
|
|
GameTooltip = nil; slash('item-info 500001'); assert(definitions[500001].tooltipStatus == 'unsupported')
|
|
GameTooltip = hidden; slash('item-info 500001'); assert(definitions[500001].tooltipStatus == 'not-public')
|
|
GameTooltip = {SetOwner = function() error(secret) end, ClearAllPoints = function() end,
|
|
SetPoint = function() end, SetItemByID = function() end, Show = function() end}
|
|
slash('item-info 500001'); assert(definitions[500001].tooltipStatus == 'failed')
|
|
GameTooltip = tooltip
|
|
GatewayDiagnosticsSaved.itemDefinitions = {}; C_Item = {}
|
|
for id = 1, 16 do slash('item-info ' .. id) end
|
|
definitions = GatewayDiagnosticsSaved.itemDefinitions
|
|
beforeTooltip = #tooltipCalls; slash('item-info 17')
|
|
assert(definitions[17] == nil and #tooltipCalls == beforeTooltip)
|
|
C_Item = api(good(1)); slash('item-info 1'); assert(definitions[1].name == 'Source-backed item')
|
|
local allowed = {name = true, itemID = true, quality = true, itemLevel = true, reqLevel = true,
|
|
maxStack = true, sellPrice = true, classID = true, subclassID = true, inventoryType = true,
|
|
icon = true, infoStatus = true, instantStatus = true, inventoryStatus = true, tooltipStatus = true}
|
|
local count = 0
|
|
for _, value in pairs(definitions) do
|
|
count = count + 1
|
|
for key in pairs(value) do assert(allowed[key]) end
|
|
end
|
|
assert(count == 16 and frames == 1)
|
|
for _, line in ipairs(lines) do
|
|
for _, value in ipairs(line) do
|
|
assert(type(value) == 'number' or type(value) == 'string')
|
|
if type(value) == 'string' then assert(not value:find(secret, 1, true)) end
|
|
end
|
|
end
|
|
print = originalPrint
|
|
print('Item-info probe: pinned C_Item tuples, public-only fields, nil/basic distinction, sixteen-ID bound and original tooltip request passed.')
|