Skip to content

Commit

Permalink
110005 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
opussf committed Oct 27, 2024
1 parent ea1fbdb commit 1ddf95a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INTERFACE=110002
INTERFACE=110005
ADDONLOC=/Applications/World of Warcraft/_retail_/Interface/Addons
62 changes: 43 additions & 19 deletions test/wowStubs.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-----------------------------------------
-- Author : Opussf
-- Date : August 13 2024
-- Revision: 9.4.3-17-g11678c7
-- Date : September 30 2024
-- Revision: 9.5-10-g3db6671
-----------------------------------------
-- These are functions from wow that have been needed by addons so far
-- Not a complete list of the functions.
Expand All @@ -12,6 +12,7 @@
-- * Create test.lua - Add #!/usr/bin/env lua
-- * require "wowTest"
-- * set test.outFileName to an ouput.xml file
-- * set test.coberturaFileName = "../coverage.xml" to enable coverage output
-- * Parse the TOC - ParseTOC( "../src/sonthing.toc" )
-- * Setup any 'Normal Frames'

Expand Down Expand Up @@ -333,7 +334,7 @@ format = string.format
strmatch = string.match
strfind = string.find
strsub = string.sub
strtolower = string.lower
strlower = string.lower
strlen = string.len
time = os.time
date = os.date
Expand Down Expand Up @@ -618,6 +619,8 @@ end
EditBox = {
["SetText"] = function(self,text) self.text=text; end,
["SetCursorPosition"] = function(self,pos) self.cursorPosition=pos; end,
["HighlightText"] = function(self,start,last) end,
["IsNumeric"] = function() end,
}
function CreateEditBox( name, ... )
me = {}
Expand Down Expand Up @@ -1263,17 +1266,7 @@ function GetTradeSkillRecipeLink( index )
return TradeSkillItems[index].elink
end
function GetUnitName( lookupStr )
lookupStr = string.lower( lookupStr )
-- return the player's UnitName if asking for "player"
if lookupStr == "player" then
return UnitName( lookupStr )
end
_, _, partyType, partyIndex = string.find( lookupStr, "(%S+)(%d+)" )
partyIndex = tonumber( partyIndex )
-- only return the indexed playername if the party type matches, and the index exists
if( myParty[partyType] and myParty.roster[partyIndex] ) then
return myParty.roster[partyIndex]
end
error("This is deprecated")
end
function GetUnitSpeed( lookupStr )
lookupStr = string.lower( lookupStr )
Expand Down Expand Up @@ -1566,9 +1559,16 @@ end
function UnitClass( who )
return Units[who].class, Units[who].classCAPS, Units[who].classIndex
end
function UnitExists( who )
return Units[who] and true or nil
end
function UnitGUID( who )
return "playerGUID"
end
function UnitGroupRolesAssigned( who )
print( "UnitGroupRolesAssigned( "..who.." )")
return Units[who].role
end
function UnitHealthMax( who )
-- http://wowwiki.wikia.com/wiki/API_UnitHealth
return Units[who].maxHealth
Expand Down Expand Up @@ -1925,6 +1925,21 @@ Menu = {}
function Menu.ModifyMenu( ... )
end

----------
-- C_Timer
----------
C_Timer = {}
function C_Timer.After( seconds, callback )
end

----------
-- C_QuestLog
----------
C_QuestLog = {}
function C_QuestLog.IsQuestFlaggedCompleted()
return false
end

-- A SAX parser takes a content handler, which provides these methods:
-- startDocument() -- called at the start of the Document
-- endDocument() -- called at the end of the Document
Expand Down Expand Up @@ -2075,16 +2090,25 @@ function saxParser.parse( fileIn )
end
end
function ParseXML( xmlFile )
parents = {}
ch = contentHandler
ch.startElement = function( self, tagIn, attribs )
if _G["Create"..tagIn] then
if attribs.name then
_G[attribs.name] = _G["Create"..tagIn]( attribs.name )
_G[attribs.name].framename = attribs.name
else
fail("A "..tagIn.." needs a name")
if (attribs.name and (not attribs.virtual or attribs.virtual == "false")) then
-- print("Create: "..attribs.name..">"..(#parents > 0 and string.gsub(attribs.name, "$parent", parents[#parents]) or "") )
frameName = (#parents > 0 and string.gsub(attribs.name, "$parent", parents[#parents]) or attribs.name)
_G[frameName] = _G["Create"..tagIn]( frameName )
_G[frameName].framename = frameName
end
end
if string.find( tagIn, "Frame$") then
table.insert( parents, attribs.name )
end
end
ch.endElement = function( self, tagIn )
if string.find( tagIn, "Frame$" ) then
table.remove( parents )
end
end
parser = saxParser.makeParser()
parser.setContentHandler( ch )
Expand Down
28 changes: 26 additions & 2 deletions test/wowTest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-----------------------------------------
-- Author : Opussf
-- Date : August 13 2024
-- Revision: 9.4.3-17-g11678c7
-- Date : September 30 2024
-- Revision: 9.5-10-g3db6671
-----------------------------------------
-- This is an uber simple unit test implementation
-- It creates a dictionary called test.
Expand All @@ -22,6 +22,30 @@ function assertEquals( expected, actual, msg )
return 1 -- passed
end
end
function assertAlmostEquals( expected, actual, msg, places, delta)
-- compute difference,
-- round to places and compare to 0
-- if delta is given, difference must be less or equal to delta
places = tonumber(places) or 7
delta = delta and tonumber(delta) or nil
msg = msg or ( "Failure: expected ("..(expected or "nil")..") actual ("..(actual or "nil")..")" )
diff = math.abs( expected - actual )

if delta and delta == tonumber(delta) then
if diff > delta then
error( msg.." difference exceeds delta ("..delta..")" )
else
return 1
end
else
diff = tonumber( string.format( "%."..places.."f", diff ) )
if diff > 0 then
error( msg.." difference ("..diff..") is within "..places.." places." )
else
return 1
end
end
end
function assertIsNil( expected, msg )
msg = msg or ("Failure: Expected nil value")
if expected and expected ~= nil then
Expand Down

0 comments on commit 1ddf95a

Please sign in to comment.