annotate Libs/LibStub/tests/test2.lua @ 0:fc346da3afd9

First commit Hot Corners standalone.
author tercio
date Fri, 08 Aug 2014 12:35:17 -0300
parents
children
rev   line source
tercio@0 1 debugstack = debug.traceback
tercio@0 2 strmatch = string.match
tercio@0 3
tercio@0 4 loadfile("../LibStub.lua")()
tercio@0 5
tercio@0 6 for major, library in LibStub:IterateLibraries() do
tercio@0 7 -- check that MyLib doesn't exist yet, by iterating through all the libraries
tercio@0 8 assert(major ~= "MyLib")
tercio@0 9 end
tercio@0 10
tercio@0 11 assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking
tercio@0 12 assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error.
tercio@0 13 local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib
tercio@0 14 assert(lib) -- check it exists
tercio@0 15 assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference
tercio@0 16
tercio@0 17 assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version
tercio@0 18
tercio@0 19 local count=0
tercio@0 20 for major, library in LibStub:IterateLibraries() do
tercio@0 21 -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries
tercio@0 22 if major == "MyLib" then -- we found it!
tercio@0 23 count = count +1
tercio@0 24 assert(rawequal(library, lib)) -- verify that the references are equal
tercio@0 25 end
tercio@0 26 end
tercio@0 27 assert(count == 1) -- verify that we actually found it, and only once