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