Mercurial > wow > askmrrobot
comparison libs/LibStub/tests/test2.lua @ 0:ec731d2fe6ba
Version 1.2.12.0
| author | Adam tegen <adam.tegen@gmail.com> |
|---|---|
| date | Tue, 20 May 2014 21:43:23 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:ec731d2fe6ba |
|---|---|
| 1 debugstack = debug.traceback | |
| 2 strmatch = string.match | |
| 3 | |
| 4 loadfile("../LibStub.lua")() | |
| 5 | |
| 6 for major, library in LibStub:IterateLibraries() do | |
| 7 -- check that MyLib doesn't exist yet, by iterating through all the libraries | |
| 8 assert(major ~= "MyLib") | |
| 9 end | |
| 10 | |
| 11 assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking | |
| 12 assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error. | |
| 13 local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib | |
| 14 assert(lib) -- check it exists | |
| 15 assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference | |
| 16 | |
| 17 assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version | |
| 18 | |
| 19 local count=0 | |
| 20 for major, library in LibStub:IterateLibraries() do | |
| 21 -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries | |
| 22 if major == "MyLib" then -- we found it! | |
| 23 count = count +1 | |
| 24 assert(rawequal(library, lib)) -- verify that the references are equal | |
| 25 end | |
| 26 end | |
| 27 assert(count == 1) -- verify that we actually found it, and only once |
