adam@3: debugstack = debug.traceback adam@3: strmatch = string.match adam@3: adam@3: loadfile("../LibStub.lua")() adam@3: adam@3: for major, library in LibStub:IterateLibraries() do adam@3: -- check that MyLib doesn't exist yet, by iterating through all the libraries adam@3: assert(major ~= "MyLib") adam@3: end adam@3: adam@3: assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking adam@3: assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error. adam@3: local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib adam@3: assert(lib) -- check it exists adam@3: assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference adam@3: adam@3: assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version adam@3: adam@3: local count=0 adam@3: for major, library in LibStub:IterateLibraries() do adam@3: -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries adam@3: if major == "MyLib" then -- we found it! adam@3: count = count +1 adam@3: assert(rawequal(library, lib)) -- verify that the references are equal adam@3: end adam@3: end adam@3: assert(count == 1) -- verify that we actually found it, and only once