adam@0
|
1 debugstack = debug.traceback
|
adam@0
|
2 strmatch = string.match
|
adam@0
|
3
|
adam@0
|
4 loadfile("../LibStub.lua")()
|
adam@0
|
5
|
adam@0
|
6 local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
|
adam@0
|
7 assert(lib) -- should return the library table
|
adam@0
|
8 assert(not oldMinor) -- should not return the old minor, since it didn't exist
|
adam@0
|
9
|
adam@0
|
10 -- the following is to create data and then be able to check if the same data exists after the fact
|
adam@0
|
11 function lib:MyMethod()
|
adam@0
|
12 end
|
adam@0
|
13 local MyMethod = lib.MyMethod
|
adam@0
|
14 lib.MyTable = {}
|
adam@0
|
15 local MyTable = lib.MyTable
|
adam@0
|
16
|
adam@0
|
17 local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
|
adam@0
|
18 assert(not newLib) -- should not return since out of date
|
adam@0
|
19
|
adam@0
|
20 local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
|
adam@0
|
21 assert(not newLib) -- should not return since out of date
|
adam@0
|
22
|
adam@0
|
23 local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
|
adam@0
|
24 assert(newLib) -- library table
|
adam@0
|
25 assert(rawequal(newLib, lib)) -- should be the same reference as the previous
|
adam@0
|
26 assert(newOldMinor == 1) -- should return the minor version of the previous version
|
adam@0
|
27
|
adam@0
|
28 assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
|
adam@0
|
29 assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
|
adam@0
|
30
|
adam@0
|
31 local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
|
adam@0
|
32 assert(newLib) -- library table
|
adam@0
|
33 assert(newOldMinor == 2) -- previous version was 2
|
adam@0
|
34
|
adam@0
|
35 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)
|
adam@0
|
36 assert(newLib)
|
adam@0
|
37 assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
|
adam@0
|
38
|
adam@0
|
39 local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
|
adam@0
|
40 assert(newLib)
|
adam@0
|
41 assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string) |