Skip to content

Commit

Permalink
adds checks for version
Browse files Browse the repository at this point in the history
  • Loading branch information
George Cook committed Jul 19, 2019
1 parent dba439c commit 17b9d83
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 131 deletions.
111 changes: 68 additions & 43 deletions dist/rooibosDist.brs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,42 @@ function Rooibos__Init(preTestSetup = invalid, testUtilsDecoratorMethodName = in
? "#TEST START : ###" ; testId ; "###"
args.testScene = scene
args.global = m.global
runner = RBS_TR_TestRunner(args)
runner.Run()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
return
rooibosVersion = "3.1"
requiredRooibosPreprocessorVersion = "3.1.0"
if not RBS_CMN_isFunction(RBSFM_getPreprocessorVersion)
versionError = "You are using a rooibos-preprocessor (i.e. rooibosC) version older than 3.1 - please update to " + requiredRooibosPreprocessorVersion
else
if RBSFM_getPreprocessorVersion() = requiredRooibosPreprocessorVersion
versionError = ""
else
versionError = "Your rooibos-preprocessor (i.e. rooibosC) version '" + RBSFM_getPreprocessorVersion() + "' is not compatible with rooibos version " + rooibosVersion + ". Please upgrade your rooibos-preprocessor to version " + requiredRooibosPreprocessorVersion
end if
end if
if versionError = ""
? "######################################################"
? ""
? "# rooibos framework version: " ; rooibosVersion
? "# tests parsed with rooibosC version: " ; rooibosVersion
? "######################################################"
? ""
runner = RBS_TR_TestRunner(args)
runner.Run()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed()
return
end if
end if
end if
end while
end while
else
? ""
? "#########################################################"
? "ERROR - VERSION MISMATCH"
? versionError
? "#########################################################"
end if
end function
function BaseTestSuite() as object
this = {}
Expand Down Expand Up @@ -1253,10 +1278,10 @@ function RBS_BTS_CleanMocks() as void
if result = invalid then return default
return result
end function
function RBS_CMN_IsXmlElement(value ) as boolean
function RBS_CMN_IsXmlElement(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifXMLElement") <> invalid
end function
function RBS_CMN_IsFunction(value ) as boolean
function RBS_CMN_IsFunction(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifFunction") <> invalid
end function
function RBS_CMN_GetFunction(filename, functionName) as object
Expand All @@ -1265,7 +1290,7 @@ function RBS_CMN_GetFunction(filename, functionName) as object
mapFunction = RBSFM_getFunctionsForFile(filename)
if mapFunction <> invalid
map = mapFunction()
if (type(map) ="roAssociativeArray")
if (type(map) = "roAssociativeArray")
functionPointer = map[functionName]
return functionPointer
else
Expand All @@ -1282,7 +1307,7 @@ function RBS_CMN_GetFunctionBruteForce(functionName) as object
mapFunction = RBSFM_getFunctionsForFile(filename)
if mapFunction <> invalid
map = mapFunction()
if (type(map) ="roAssociativeArray")
if (type(map) = "roAssociativeArray")
functionPointer = map[functionName]
if functionPointer <> invalid
return functionPointer
Expand All @@ -1292,59 +1317,59 @@ function RBS_CMN_GetFunctionBruteForce(functionName) as object
end for
return invalid
end function
function RBS_CMN_IsBoolean(value ) as boolean
function RBS_CMN_IsBoolean(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifBoolean") <> invalid
end function
function RBS_CMN_IsInteger(value ) as boolean
function RBS_CMN_IsInteger(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifInt") <> invalid and (Type(value) = "roInt" or Type(value) = "roInteger" or Type(value) = "Integer")
end function
function RBS_CMN_IsFloat(value ) as boolean
function RBS_CMN_IsFloat(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifFloat") <> invalid
end function
function RBS_CMN_IsDouble(value ) as boolean
function RBS_CMN_IsDouble(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifDouble") <> invalid
end function
function RBS_CMN_IsLongInteger(value ) as boolean
function RBS_CMN_IsLongInteger(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifLongInt") <> invalid
end function
function RBS_CMN_IsNumber(value ) as boolean
function RBS_CMN_IsNumber(value) as boolean
return RBS_CMN_IsLongInteger(value) or RBS_CMN_IsDouble(value) or RBS_CMN_IsInteger(value) or RBS_CMN_IsFloat(value)
end function
function RBS_CMN_IsList(value ) as boolean
function RBS_CMN_IsList(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifList") <> invalid
end function
function RBS_CMN_IsArray(value ) as boolean
function RBS_CMN_IsArray(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifArray") <> invalid
end function
function RBS_CMN_IsAssociativeArray(value ) as boolean
function RBS_CMN_IsAssociativeArray(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifAssociativeArray") <> invalid
end function
function RBS_CMN_IsSGNode(value ) as boolean
function RBS_CMN_IsSGNode(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifSGNodeChildren") <> invalid
end function
function RBS_CMN_IsString(value ) as boolean
function RBS_CMN_IsString(value) as boolean
return RBS_CMN_IsValid(value) and GetInterface(value, "ifString") <> invalid
end function
function RBS_CMN_IsNotEmptyString(value ) as boolean
function RBS_CMN_IsNotEmptyString(value) as boolean
return RBS_CMN_IsString(value) and len(value) > 0
end function
function RBS_CMN_IsDateTime(value ) as boolean
function RBS_CMN_IsDateTime(value) as boolean
return RBS_CMN_IsValid(value) and (GetInterface(value, "ifDateTime") <> invalid or Type(value) = "roDateTime")
end function
function RBS_CMN_IsValid(value ) as boolean
function RBS_CMN_IsValid(value) as boolean
return not RBS_CMN_IsUndefined(value) and value <> invalid
end function
function RBS_CMN_IsUndefined(value ) as boolean
function RBS_CMN_IsUndefined(value) as boolean
return type(value) = "" or Type(value) = "<uninitialized>"
end function
function RBS_CMN_ValidStr(obj ) as string
function RBS_CMN_ValidStr(obj) as string
if obj <> invalid and GetInterface(obj, "ifString") <> invalid
return obj
else
return ""
end if
end function
function RBS_CMN_AsString(input ) as string
function RBS_CMN_AsString(input) as string
if RBS_CMN_IsValid(input) = false
return ""
else if RBS_CMN_IsString(input)
Expand All @@ -1354,7 +1379,7 @@ function RBS_CMN_AsString(input ) as string
else if RBS_CMN_IsFloat(input) or RBS_CMN_IsDouble(input)
return Str(input).Trim()
else if type(input) = "roSGNode"
return "Node(" + input.subType() +")"
return "Node(" + input.subType() + ")"
else if type(input) = "roAssociativeArray"
isFirst = true
text = "{"
Expand All @@ -1373,7 +1398,7 @@ function RBS_CMN_AsString(input ) as string
return ""
end if
end function
function RBS_CMN_AsInteger(input ) as integer
function RBS_CMN_AsInteger(input) as integer
if RBS_CMN_IsValid(input) = false
return 0
else if RBS_CMN_IsString(input)
Expand All @@ -1386,7 +1411,7 @@ function RBS_CMN_AsInteger(input ) as integer
return 0
end if
end function
function RBS_CMN_AsLongInteger(input ) as longinteger
function RBS_CMN_AsLongInteger(input) as longinteger
if RBS_CMN_IsValid(input) = false
return 0
else if RBS_CMN_IsString(input)
Expand All @@ -1397,7 +1422,7 @@ function RBS_CMN_AsLongInteger(input ) as longinteger
return 0
end if
end function
function RBS_CMN_AsFloat(input ) as float
function RBS_CMN_AsFloat(input) as float
if RBS_CMN_IsValid(input) = false
return 0.0
else if RBS_CMN_IsString(input)
Expand All @@ -1410,7 +1435,7 @@ function RBS_CMN_AsFloat(input ) as float
return 0.0
end if
end function
function RBS_CMN_AsDouble(input ) as double
function RBS_CMN_AsDouble(input) as double
if RBS_CMN_IsValid(input) = false
return 0.0
else if RBS_CMN_IsString(input)
Expand All @@ -1421,7 +1446,7 @@ function RBS_CMN_AsDouble(input ) as double
return 0.0
end if
end function
function RBS_CMN_AsBoolean(input ) as boolean
function RBS_CMN_AsBoolean(input) as boolean
if RBS_CMN_IsValid(input) = false
return false
else if RBS_CMN_IsString(input)
Expand All @@ -1434,7 +1459,7 @@ function RBS_CMN_AsBoolean(input ) as boolean
return false
end if
end function
function RBS_CMN_AsArray(value ) as object
function RBS_CMN_AsArray(value) as object
if RBS_CMN_IsValid(value)
if not RBS_CMN_IsArray(value)
return [value]
Expand All @@ -1444,14 +1469,14 @@ function RBS_CMN_AsArray(value ) as object
end if
return []
end function
function RBS_CMN_IsNullOrEmpty(value ) as boolean
function RBS_CMN_IsNullOrEmpty(value) as boolean
if RBS_CMN_IsString(value)
return Len(value) = 0
else
return not RBS_CMN_IsValid(value)
end if
end function
function RBS_CMN_FindElementIndexInArray(array , value , compareAttribute = invalid , caseSensitive = false ) as integer
function RBS_CMN_FindElementIndexInArray(array , value , compareAttribute = invalid , caseSensitive = false) as integer
if RBS_CMN_IsArray(array)
for i = 0 to RBS_CMN_AsArray(array).Count() - 1
compareValue = array[i]
Expand All @@ -1466,10 +1491,10 @@ function RBS_CMN_FindElementIndexInArray(array , value , compareAttribute = inva
end if
return -1
end function
function RBS_CMN_ArrayContains(array , value , compareAttribute = invalid ) as boolean
function RBS_CMN_ArrayContains(array , value , compareAttribute = invalid) as boolean
return (RBS_CMN_FindElementIndexInArray(array, value, compareAttribute) > -1)
end function
function RBS_CMN_FindElementIndexInNode(node , value ) as integer
function RBS_CMN_FindElementIndexInNode(node , value) as integer
if type(node) = "roSGNode"
for i = 0 to node.getChildCount() - 1
compareValue = node.getChild(i)
Expand All @@ -1480,7 +1505,7 @@ function RBS_CMN_FindElementIndexInNode(node , value ) as integer
end if
return -1
end function
function RBS_CMN_NodeContains(node , value ) as boolean
function RBS_CMN_NodeContains(node , value) as boolean
return (RBS_CMN_FindElementIndexInNode(node, value) > -1)
end function
function RBS_ItG_GetTestCases(group) as object
Expand Down
51 changes: 23 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rooibos",
"version": "3.0.4",
"version": "3.1.0",
"description": "simple, flexible, fun brihhtscript test framework for roku scenegraph apps",
"main": "index.js",
"directories": {
Expand All @@ -22,7 +22,7 @@
"jsdoc": "3.5.5",
"minami": "^1.2.3",
"roku-deploy": "^2.0.0",
"rooibos-preprocessor": "^3.0.6-beta",
"rooibos-preprocessor": "^3.1.0",
"typescript": "^3.3.1",
"vinyl-paths": "^2.1.0"
},
Expand Down
Loading

0 comments on commit 17b9d83

Please sign in to comment.