annotate Libs/LibStub/tests/test4.lua @ 0:0de01324b4f2

first commit
author Tercio
date Tue, 23 Jun 2015 15:26:28 -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
Tercio@0 7 -- Pretend like loaded libstub is old and doesn't have :IterateLibraries
Tercio@0 8 assert(LibStub.minor)
Tercio@0 9 LibStub.minor = LibStub.minor - 0.0001
Tercio@0 10 LibStub.IterateLibraries = nil
Tercio@0 11
Tercio@0 12 loadfile("../LibStub.lua")()
Tercio@0 13
Tercio@0 14 assert(type(LibStub.IterateLibraries)=="function")
Tercio@0 15
Tercio@0 16
Tercio@0 17 -- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created
Tercio@0 18 LibStub.IterateLibraries = 123
Tercio@0 19
Tercio@0 20 loadfile("../LibStub.lua")()
Tercio@0 21
Tercio@0 22 assert(LibStub.IterateLibraries == 123)
Tercio@0 23
Tercio@0 24
Tercio@0 25 -- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created
Tercio@0 26 LibStub.minor = LibStub.minor + 0.0001
Tercio@0 27
Tercio@0 28 loadfile("../LibStub.lua")()
Tercio@0 29
Tercio@0 30 assert(LibStub.IterateLibraries == 123)
Tercio@0 31
Tercio@0 32
Tercio@0 33 -- Again with a huge number
Tercio@0 34 LibStub.minor = LibStub.minor + 1234567890
Tercio@0 35
Tercio@0 36 loadfile("../LibStub.lua")()
Tercio@0 37
Tercio@0 38 assert(LibStub.IterateLibraries == 123)
Tercio@0 39
Tercio@0 40
Tercio@0 41 print("OK")