Tercio@4: debugstack = debug.traceback Tercio@4: strmatch = string.match Tercio@4: Tercio@4: loadfile("../LibStub.lua")() Tercio@4: Tercio@4: local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy Tercio@4: assert(lib) -- should return the library table Tercio@4: assert(not oldMinor) -- should not return the old minor, since it didn't exist Tercio@4: Tercio@4: -- the following is to create data and then be able to check if the same data exists after the fact Tercio@4: function lib:MyMethod() Tercio@4: end Tercio@4: local MyMethod = lib.MyMethod Tercio@4: lib.MyTable = {} Tercio@4: local MyTable = lib.MyTable Tercio@4: Tercio@4: local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail Tercio@4: assert(not newLib) -- should not return since out of date Tercio@4: Tercio@4: local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail Tercio@4: assert(not newLib) -- should not return since out of date Tercio@4: Tercio@4: local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version Tercio@4: assert(newLib) -- library table Tercio@4: assert(rawequal(newLib, lib)) -- should be the same reference as the previous Tercio@4: assert(newOldMinor == 1) -- should return the minor version of the previous version Tercio@4: Tercio@4: assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved Tercio@4: assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved Tercio@4: Tercio@4: local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number) Tercio@4: assert(newLib) -- library table Tercio@4: assert(newOldMinor == 2) -- previous version was 2 Tercio@4: Tercio@4: local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number) Tercio@4: assert(newLib) Tercio@4: assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string) Tercio@4: Tercio@4: local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string Tercio@4: assert(newLib) Tercio@4: assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)