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