debugstack=debug.traceback strmatch=string.match;(loadfile("\046\046\047\076\105\098\083\116\117\098\046\108\117\097"))()local c,y=LibStub:NewLibrary("\080\097\110\116\115",1)assert(c)assert(not y)function c.MyMethod(c) end local K=c.MyMethod c.MyTable={}local T=c.MyTable local X,z=LibStub:NewLibrary("\080\097\110\116\115",1)assert(not X)local B,L=LibStub:NewLibrary("\080\097\110\116\115",0)assert(not B)local P,H=LibStub:NewLibrary("\080\097\110\116\115",2)assert(P)assert(rawequal(P,c))assert(H==1)assert(rawequal(c.MyMethod,K))assert(rawequal(c.MyTable,T))local F,w=LibStub:NewLibrary("\080\097\110\116\115","\066\108\097\104 \051 \066\108\097\104")assert(F)assert(w==2)local p,Q=LibStub:NewLibrary("\080\097\110\116\115","\066\108\097\104 \052 \097\110\100 \112\108\101\097\115\101 \105\103\110\111\114\101 \049\053 \066\108\097\104")assert(p)assert(Q==3)local o,v=LibStub:NewLibrary("\080\097\110\116\115",5)assert(o)assert(v==4)
debugstack = debug.traceback
strmatch = string.match

loadfile("../LibStub.lua")()

local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
assert(lib) -- should return the library table
assert(not oldMinor) -- should not return the old minor, since it didn't exist

-- the following is to create data and then be able to check if the same data exists after the fact
function lib:MyMethod()
end
local MyMethod = lib.MyMethod
lib.MyTable = {}
local MyTable = lib.MyTable

local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
assert(not newLib) -- should not return since out of date

local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
assert(not newLib) -- should not return since out of date

local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
assert(newLib) -- library table
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
assert(newOldMinor == 1) -- should return the minor version of the previous version

assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved

local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
assert(newLib) -- library table
assert(newOldMinor == 2) -- previous version was 2

local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number)
assert(newLib)
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)

local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
assert(newLib)
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)