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