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