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