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