WoWInterface SVN NeedyGreedy

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/libs/LibQTip-1.0
    from Rev 139 to Rev 145
    Reverse comparison

Rev 139 → Rev 145

LibStub/tests/test.lua New file
0,0 → 1,41
debugstack = debug.traceback
strmatch = string.match
 
loadfile("../LibStub.lua")()
 
local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy
assert(lib) -- should return the library table
assert(not oldMinor) -- should not return the old minor, since it didn't exist
 
-- the following is to create data and then be able to check if the same data exists after the fact
function lib:MyMethod()
end
local MyMethod = lib.MyMethod
lib.MyTable = {}
local MyTable = lib.MyTable
 
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail
assert(not newLib) -- should not return since out of date
 
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail
assert(not newLib) -- should not return since out of date
 
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version
assert(newLib) -- library table
assert(rawequal(newLib, lib)) -- should be the same reference as the previous
assert(newOldMinor == 1) -- should return the minor version of the previous version
 
assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved
assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved
 
local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number)
assert(newLib) -- library table
assert(newOldMinor == 2) -- previous version was 2
 
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)
assert(newLib)
assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string)
 
local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string
assert(newLib)
assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string)
\ No newline at end of file
LibStub/tests/test2.lua New file
0,0 → 1,27
debugstack = debug.traceback
strmatch = string.match
 
loadfile("../LibStub.lua")()
 
for major, library in LibStub:IterateLibraries() do
-- check that MyLib doesn't exist yet, by iterating through all the libraries
assert(major ~= "MyLib")
end
 
assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
assert(lib) -- check it exists
assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
 
assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
 
local count=0
for major, library in LibStub:IterateLibraries() do
-- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
if major == "MyLib" then -- we found it!
count = count +1
assert(rawequal(library, lib)) -- verify that the references are equal
end
end
assert(count == 1) -- verify that we actually found it, and only once
LibStub/tests/test3.lua New file
0,0 → 1,14
debugstack = debug.traceback
strmatch = string.match
 
loadfile("../LibStub.lua")()
 
local proxy = newproxy() -- non-string
 
assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata
local success, ret = pcall(LibStub.GetLibrary, proxy, true)
assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered.
 
assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it.
 
assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement
\ No newline at end of file
LibStub/tests/test4.lua New file
0,0 → 1,41
debugstack = debug.traceback
strmatch = string.match
 
loadfile("../LibStub.lua")()
 
 
-- Pretend like loaded libstub is old and doesn't have :IterateLibraries
assert(LibStub.minor)
LibStub.minor = LibStub.minor - 0.0001
LibStub.IterateLibraries = nil
 
loadfile("../LibStub.lua")()
 
assert(type(LibStub.IterateLibraries)=="function")
 
 
-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
LibStub.IterateLibraries = 123
 
loadfile("../LibStub.lua")()
 
assert(LibStub.IterateLibraries == 123)
 
 
-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
LibStub.minor = LibStub.minor + 0.0001
 
loadfile("../LibStub.lua")()
 
assert(LibStub.IterateLibraries == 123)
 
 
-- Again with a huge number
LibStub.minor = LibStub.minor + 1234567890
 
loadfile("../LibStub.lua")()
 
assert(LibStub.IterateLibraries == 123)
 
 
print("OK")
\ No newline at end of file
Changelog-LibQTip-1.0-r152-release.txt New file
0,0 → 1,13
------------------------------------------------------------------------
r152 | torhal | 2011-04-27 08:11:19 +0000 (Wed, 27 Apr 2011) | 1 line
Changed paths:
A /tags/r152-release (from /trunk:151)
 
Tagging as r152-release
------------------------------------------------------------------------
r151 | torhal | 2011-04-27 08:09:30 +0000 (Wed, 27 Apr 2011) | 1 line
Changed paths:
M /trunk/LibQTip-1.0.toc
 
Updated ToC version for WoW 4.1
------------------------------------------------------------------------