annotate Libs/LibStub/tests/test.lua @ 31:44c285acfff0 v8

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