rooibos-roku 5.7.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -332,7 +332,7 @@ namespace rooibos
332
332
  return false
333
333
  end if
334
334
  try
335
- if Rooibos.Common.isBoolean(expr)
335
+ if rooibos.common.isBoolean(expr)
336
336
  if expr
337
337
  return m.fail(msg)
338
338
  end if
@@ -362,7 +362,7 @@ namespace rooibos
362
362
  return false
363
363
  end if
364
364
  try
365
- if Rooibos.Common.isBoolean(expr)
365
+ if rooibos.common.isBoolean(expr)
366
366
  if not expr
367
367
  return m.fail(msg)
368
368
  end if
@@ -394,10 +394,10 @@ namespace rooibos
394
394
  return false
395
395
  end if
396
396
  try
397
- if not Rooibos.Common.eqValues(first, second)
397
+ if not rooibos.common.eqValues(first, second)
398
398
  if msg = ""
399
- first_as_string = Rooibos.Common.asString(first, true)
400
- second_as_string = Rooibos.Common.asString(second, true)
399
+ first_as_string = rooibos.common.asString(first, true)
400
+ second_as_string = rooibos.common.asString(second, true)
401
401
  msg = first_as_string + " != " + second_as_string
402
402
  end if
403
403
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -428,10 +428,10 @@ namespace rooibos
428
428
  return false
429
429
  end if
430
430
  try
431
- if not Rooibos.Common.eqValues(first, second, true)
431
+ if not rooibos.common.eqValues(first, second, true)
432
432
  if msg = ""
433
- first_as_string = Rooibos.Common.asString(first)
434
- second_as_string = Rooibos.Common.asString(second)
433
+ first_as_string = rooibos.common.asString(first)
434
+ second_as_string = rooibos.common.asString(second)
435
435
  msg = first_as_string + " != " + second_as_string
436
436
  end if
437
437
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -462,10 +462,10 @@ namespace rooibos
462
462
  return false
463
463
  end if
464
464
  try
465
- if Rooibos.Common.eqValues(first, second)
465
+ if rooibos.common.eqValues(first, second)
466
466
  if msg = ""
467
- first_as_string = Rooibos.Common.asString(first, true)
468
- second_as_string = Rooibos.Common.asString(second, true)
467
+ first_as_string = rooibos.common.asString(first, true)
468
+ second_as_string = rooibos.common.asString(second, true)
469
469
  msg = first_as_string + " == " + second_as_string
470
470
  end if
471
471
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -498,7 +498,7 @@ namespace rooibos
498
498
  try
499
499
  if value <> invalid
500
500
  if msg = ""
501
- expr_as_string = Rooibos.Common.asString(value, true)
501
+ expr_as_string = rooibos.common.asString(value, true)
502
502
  msg = expr_as_string + " <> Invalid"
503
503
  end if
504
504
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -560,7 +560,7 @@ namespace rooibos
560
560
  return false
561
561
  end if
562
562
  try
563
- if Rooibos.Common.isAssociativeArray(array)
563
+ if rooibos.common.isAssociativeArray(array)
564
564
  if not array.DoesExist(key)
565
565
  if msg = ""
566
566
  msg = "Array doesn't have the '" + key + "' key."
@@ -599,7 +599,7 @@ namespace rooibos
599
599
  end if
600
600
 
601
601
  try
602
- if Rooibos.Common.isAssociativeArray(array)
602
+ if rooibos.common.isAssociativeArray(array)
603
603
  if array.DoesExist(key)
604
604
  if msg = ""
605
605
  msg = "Array has the '" + key + "' key."
@@ -638,7 +638,7 @@ namespace rooibos
638
638
  end if
639
639
 
640
640
  try
641
- if Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isArray(keys)
641
+ if rooibos.common.isAssociativeArray(array) and rooibos.common.isArray(keys)
642
642
  for each key in keys
643
643
  if not array.DoesExist(key)
644
644
  if msg = ""
@@ -678,7 +678,7 @@ namespace rooibos
678
678
  return false
679
679
  end if
680
680
  try
681
- if Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isArray(keys)
681
+ if rooibos.common.isAssociativeArray(array) and rooibos.common.isArray(keys)
682
682
  for each key in keys
683
683
  if array.DoesExist(key)
684
684
  if msg = ""
@@ -721,9 +721,9 @@ namespace rooibos
721
721
  return false
722
722
  end if
723
723
  try
724
- if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array)
725
- if not Rooibos.Common.arrayContains(array, value, key)
726
- msg = "Array doesn't have the '" + Rooibos.Common.asString(value, true) + "' value."
724
+ if rooibos.common.isAssociativeArray(array) or rooibos.common.isArray(array)
725
+ if not rooibos.common.arrayContains(array, value, key)
726
+ msg = "Array doesn't have the '" + rooibos.common.asString(value, true) + "' value."
727
727
  m.currentResult.fail(msg, m.currentAssertLineNumber)
728
728
  return false
729
729
  end if
@@ -757,27 +757,27 @@ namespace rooibos
757
757
  return false
758
758
  end if
759
759
  try
760
- if not Rooibos.Common.isArray(values)
760
+ if not rooibos.common.isArray(values)
761
761
  msg = "values to search for are not an Array."
762
762
  m.currentResult.fail(msg, m.currentAssertLineNumber)
763
763
  return false
764
764
  end if
765
765
 
766
- if Rooibos.Common.isArray(array)
766
+ if rooibos.common.isArray(array)
767
767
  for each value in values
768
768
  isMatched = false
769
- if not Rooibos.Common.isAssociativeArray(value)
770
- msg = "Value to search for was not associativeArray " + Rooibos.Common.asString(value, true)
769
+ if not rooibos.common.isAssociativeArray(value)
770
+ msg = "Value to search for was not associativeArray " + rooibos.common.asString(value, true)
771
771
  m.currentResult.fail(msg, m.currentAssertLineNumber)
772
772
  return false
773
773
  end if
774
774
  for each item in array
775
- if Rooibos.Common.IsAssociativeArray(item)
775
+ if rooibos.common.IsAssociativeArray(item)
776
776
  isValueMatched = true
777
777
  for each key in value
778
778
  fieldValue = value[key]
779
779
  itemValue = item[key]
780
- if not Rooibos.Common.eqValues(fieldValue, itemValue)
780
+ if not rooibos.common.eqValues(fieldValue, itemValue)
781
781
  isValueMatched = false
782
782
  exit for
783
783
  end if
@@ -790,7 +790,7 @@ namespace rooibos
790
790
  end for ' items in array
791
791
 
792
792
  if not isMatched
793
- msg = "array missing value: " + Rooibos.Common.asString(value, true)
793
+ msg = "array missing value: " + rooibos.common.asString(value, true)
794
794
  m.currentResult.fail(msg, m.currentAssertLineNumber)
795
795
  return false
796
796
  end if
@@ -828,9 +828,9 @@ namespace rooibos
828
828
  return false
829
829
  end if
830
830
  try
831
- if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array)
832
- if Rooibos.Common.arrayContains(array, value, key)
833
- msg = "Array has the '" + Rooibos.Common.asString(value, true) + "' value."
831
+ if rooibos.common.isAssociativeArray(array) or rooibos.common.isArray(array)
832
+ if rooibos.common.arrayContains(array, value, key)
833
+ msg = "Array has the '" + rooibos.common.asString(value, true) + "' value."
834
834
  m.currentResult.fail(msg, m.currentAssertLineNumber)
835
835
  return false
836
836
  end if
@@ -864,8 +864,8 @@ namespace rooibos
864
864
  return false
865
865
  end if
866
866
  try
867
- if (Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isAssociativeArray(subset)) or (Rooibos.Common.isArray(array) and Rooibos.Common.isArray(subset))
868
- isAA = Rooibos.Common.isAssociativeArray(subset)
867
+ if (rooibos.common.isAssociativeArray(array) and rooibos.common.isAssociativeArray(subset)) or (rooibos.common.isArray(array) and rooibos.common.isArray(subset))
868
+ isAA = rooibos.common.isAssociativeArray(subset)
869
869
  for each item in subset
870
870
  key = invalid
871
871
  value = item
@@ -873,8 +873,8 @@ namespace rooibos
873
873
  key = item
874
874
  value = subset[key]
875
875
  end if
876
- if not Rooibos.Common.arrayContains(array, value, key)
877
- msg = "Array doesn't have the '" + Rooibos.Common.asString(value, true) + "' value."
876
+ if not rooibos.common.arrayContains(array, value, key)
877
+ msg = "Array doesn't have the '" + rooibos.common.asString(value, true) + "' value."
878
878
  m.currentResult.fail(msg, m.currentAssertLineNumber)
879
879
  return false
880
880
  end if
@@ -909,8 +909,8 @@ namespace rooibos
909
909
  return false
910
910
  end if
911
911
  try
912
- if (Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isAssociativeArray(subset)) or (Rooibos.Common.isArray(array) and Rooibos.Common.isArray(subset))
913
- isAA = Rooibos.Common.isAssociativeArray(subset)
912
+ if (rooibos.common.isAssociativeArray(array) and rooibos.common.isAssociativeArray(subset)) or (rooibos.common.isArray(array) and rooibos.common.isArray(subset))
913
+ isAA = rooibos.common.isAssociativeArray(subset)
914
914
  for each item in subset
915
915
  key = invalid
916
916
  value = item
@@ -918,8 +918,8 @@ namespace rooibos
918
918
  key = item
919
919
  value = item[key]
920
920
  end if
921
- if Rooibos.Common.arrayContains(array, value, key)
922
- msg = "Array has the '" + Rooibos.Common.asString(value, true) + "' value."
921
+ if rooibos.common.arrayContains(array, value, key)
922
+ msg = "Array has the '" + rooibos.common.asString(value, true) + "' value."
923
923
  m.currentResult.fail(msg, m.currentAssertLineNumber)
924
924
  return false
925
925
  end if
@@ -954,9 +954,9 @@ namespace rooibos
954
954
  return false
955
955
  end if
956
956
  try
957
- if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array)
957
+ if rooibos.common.isAssociativeArray(array) or rooibos.common.isArray(array)
958
958
  if array.Count() <> count
959
- msg = "Array items count " + Rooibos.Common.asString(array.Count()) + " <> " + Rooibos.Common.asString(count) + "."
959
+ msg = "Array items count " + rooibos.common.asString(array.Count()) + " <> " + rooibos.common.asString(count) + "."
960
960
  m.currentResult.fail(msg, m.currentAssertLineNumber)
961
961
  return false
962
962
  end if
@@ -990,9 +990,9 @@ namespace rooibos
990
990
  return false
991
991
  end if
992
992
  try
993
- if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array)
993
+ if rooibos.common.isAssociativeArray(array) or rooibos.common.isArray(array)
994
994
  if array.Count() = count
995
- msg = "Array items count = " + Rooibos.Common.asString(count) + "."
995
+ msg = "Array items count = " + rooibos.common.asString(count) + "."
996
996
  m.currentResult.fail(msg, m.currentAssertLineNumber)
997
997
  return false
998
998
  end if
@@ -1025,15 +1025,15 @@ namespace rooibos
1025
1025
  return false
1026
1026
  end if
1027
1027
  try
1028
- if Rooibos.Common.isAssociativeArray(item) or Rooibos.Common.isArray(item)
1028
+ if rooibos.common.isAssociativeArray(item) or rooibos.common.isArray(item)
1029
1029
  if item.count() > 0
1030
1030
  msg = "Array is not empty."
1031
1031
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1032
1032
  return false
1033
1033
  end if
1034
- else if Rooibos.Common.isString(item)
1035
- if Rooibos.Common.asString(item) <> ""
1036
- msg = "String is not empty, contains: " + Rooibos.Common.asString(item, true)
1034
+ else if rooibos.common.isString(item)
1035
+ if rooibos.common.asString(item) <> ""
1036
+ msg = "String is not empty, contains: " + rooibos.common.asString(item, true)
1037
1037
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1038
1038
  return false
1039
1039
  end if
@@ -1066,13 +1066,13 @@ namespace rooibos
1066
1066
  return false
1067
1067
  end if
1068
1068
  try
1069
- if Rooibos.Common.isAssociativeArray(item) or Rooibos.Common.isArray(item)
1069
+ if rooibos.common.isAssociativeArray(item) or rooibos.common.isArray(item)
1070
1070
  if item.count() = 0
1071
1071
  msg = "Array is empty."
1072
1072
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1073
1073
  return false
1074
1074
  end if
1075
- else if Rooibos.Common.isString(item)
1075
+ else if rooibos.common.isString(item)
1076
1076
  if item = ""
1077
1077
  msg = "Input value is empty."
1078
1078
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -1115,13 +1115,13 @@ namespace rooibos
1115
1115
  return false
1116
1116
  end if
1117
1117
 
1118
- if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array)
1118
+ if rooibos.common.isAssociativeArray(array) or rooibos.common.isArray(array)
1119
1119
  methodName = "Rooibos_Common_Is" + typeStr
1120
1120
  typeCheckFunction = m.getIsTypeFunction(methodName)
1121
1121
  if typeCheckFunction <> invalid
1122
1122
  for each item in array
1123
1123
  if not typeCheckFunction(item)
1124
- msg = Rooibos.Common.asString(item, true) + " is not a '" + typeStr + "' type."
1124
+ msg = rooibos.common.asString(item, true) + " is not a '" + typeStr + "' type."
1125
1125
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1126
1126
  return false
1127
1127
  end if
@@ -1147,35 +1147,35 @@ namespace rooibos
1147
1147
 
1148
1148
  function getIsTypeFunction(name)
1149
1149
  if name = "Rooibos_Common_IsFunction"
1150
- return Rooibos.Common.isFunction
1150
+ return rooibos.common.isFunction
1151
1151
  else if name = "Rooibos_Common_IsXmlElement"
1152
- return Rooibos.Common.isXmlElement
1152
+ return rooibos.common.isXmlElement
1153
1153
  else if name = "Rooibos_Common_IsInteger"
1154
- return Rooibos.Common.isInteger
1154
+ return rooibos.common.isInteger
1155
1155
  else if name = "Rooibos_Common_IsBoolean"
1156
- return Rooibos.Common.isBoolean
1156
+ return rooibos.common.isBoolean
1157
1157
  else if name = "Rooibos_Common_IsFloat"
1158
- return Rooibos.Common.isFloat
1158
+ return rooibos.common.isFloat
1159
1159
  else if name = "Rooibos_Common_IsDouble"
1160
- return Rooibos.Common.isDouble
1160
+ return rooibos.common.isDouble
1161
1161
  else if name = "Rooibos_Common_IsLongInteger"
1162
- return Rooibos.Common.isLongInteger
1162
+ return rooibos.common.isLongInteger
1163
1163
  else if name = "Rooibos_Common_IsNumber"
1164
- return Rooibos.Common.isNumber
1164
+ return rooibos.common.isNumber
1165
1165
  else if name = "Rooibos_Common_IsList"
1166
- return Rooibos.Common.isList
1166
+ return rooibos.common.isList
1167
1167
  else if name = "Rooibos_Common_IsArray"
1168
- return Rooibos.Common.isArray
1168
+ return rooibos.common.isArray
1169
1169
  else if name = "Rooibos_Common_IsAssociativeArray"
1170
- return Rooibos.Common.isAssociativeArray
1170
+ return rooibos.common.isAssociativeArray
1171
1171
  else if name = "Rooibos_Common_IsSGNode"
1172
- return Rooibos.Common.isSGNode
1172
+ return rooibos.common.isSGNode
1173
1173
  else if name = "Rooibos_Common_IsString"
1174
- return Rooibos.Common.isString
1174
+ return rooibos.common.isString
1175
1175
  else if name = "Rooibos_Common_IsDateTime"
1176
- return Rooibos.Common.isDateTime
1176
+ return rooibos.common.isDateTime
1177
1177
  else if name = "Rooibos_Common_IsUndefined"
1178
- return Rooibos.Common.isUndefined
1178
+ return rooibos.common.isUndefined
1179
1179
  else
1180
1180
  return invalid
1181
1181
  end if
@@ -1199,7 +1199,7 @@ namespace rooibos
1199
1199
  try
1200
1200
  if type(value) <> typeStr
1201
1201
  if msg = ""
1202
- expr_as_string = Rooibos.Common.asString(value, true)
1202
+ expr_as_string = rooibos.common.asString(value, true)
1203
1203
  msg = expr_as_string + " was not expected type " + typeStr
1204
1204
  end if
1205
1205
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -1232,14 +1232,14 @@ namespace rooibos
1232
1232
  try
1233
1233
  if type(value) <> "roSGNode"
1234
1234
  if msg = ""
1235
- expr_as_string = Rooibos.Common.asString(value, true)
1235
+ expr_as_string = rooibos.common.asString(value, true)
1236
1236
  msg = expr_as_string + " was not a node, so could not match subtype " + typeStr
1237
1237
  end if
1238
1238
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1239
1239
  return false
1240
1240
  else if value.subType() <> typeStr
1241
1241
  if msg = ""
1242
- expr_as_string = Rooibos.Common.asString(value, true)
1242
+ expr_as_string = rooibos.common.asString(value, true)
1243
1243
  msg = expr_as_string + "( type : " + value.subType() + ") was not of subType " + typeStr
1244
1244
  end if
1245
1245
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -1258,13 +1258,13 @@ namespace rooibos
1258
1258
  if m.currentResult.isFail
1259
1259
  return false
1260
1260
  end if
1261
- if rooibos.Common.isFunction(func)
1261
+ if rooibos.common.isFunction(func)
1262
1262
  func = func.toStr().mid(10).replace("_", ".")
1263
1263
  end if
1264
1264
  try
1265
- if not Rooibos.Common.isAssociativeArray(value)
1265
+ if not rooibos.common.isAssociativeArray(value)
1266
1266
  if msg = ""
1267
- expr_as_string = Rooibos.Common.asString(value)
1267
+ expr_as_string = rooibos.common.asString(value)
1268
1268
  msg = expr_as_string + " was not an aa, so could not match Class " + func
1269
1269
  end if
1270
1270
  m.currentResult.fail(msg, m.currentAssertLineNumber)
@@ -1316,7 +1316,7 @@ namespace rooibos
1316
1316
  childCount = node.getChildCount()
1317
1317
  end if
1318
1318
  if childCount <> count
1319
- msg = "node items count <> " + Rooibos.Common.asString(count) + ". Received " + Rooibos.Common.asString(childCount)
1319
+ msg = "node items count <> " + rooibos.common.asString(count) + ". Received " + rooibos.common.asString(childCount)
1320
1320
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1321
1321
  return false
1322
1322
  end if
@@ -1358,7 +1358,7 @@ namespace rooibos
1358
1358
  childCount = node.getChildCount()
1359
1359
  end if
1360
1360
  if childCount = count
1361
- msg = "node items count = " + Rooibos.Common.asString(count) + "."
1361
+ msg = "node items count = " + rooibos.common.asString(count) + "."
1362
1362
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1363
1363
  return false
1364
1364
  end if
@@ -1460,8 +1460,8 @@ namespace rooibos
1460
1460
  end if
1461
1461
  try
1462
1462
  if type(node) = "roSGNode"
1463
- if not Rooibos.Common.nodeContains(node, value)
1464
- msg = "Node doesn't have the '" + Rooibos.Common.asString(value, true) + "' value."
1463
+ if not rooibos.common.nodeContains(node, value)
1464
+ msg = "Node doesn't have the '" + rooibos.common.asString(value, true) + "' value."
1465
1465
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1466
1466
  return false
1467
1467
  end if
@@ -1496,8 +1496,8 @@ namespace rooibos
1496
1496
  end if
1497
1497
  try
1498
1498
  if type(node) = "roSGNode"
1499
- if not Rooibos.Common.nodeContains(node, value)
1500
- msg = "Node doesn't have the '" + Rooibos.Common.asString(value, true) + "' value."
1499
+ if not rooibos.common.nodeContains(node, value)
1500
+ msg = "Node doesn't have the '" + rooibos.common.asString(value, true) + "' value."
1501
1501
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1502
1502
  return false
1503
1503
  else
@@ -1544,8 +1544,8 @@ namespace rooibos
1544
1544
  end if
1545
1545
  try
1546
1546
  if type(node) = "roSGNode"
1547
- if Rooibos.Common.nodeContains(node, value)
1548
- msg = "Node has the '" + Rooibos.Common.asString(value, true) + "' value."
1547
+ if rooibos.common.nodeContains(node, value)
1548
+ msg = "Node has the '" + rooibos.common.asString(value, true) + "' value."
1549
1549
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1550
1550
  return false
1551
1551
  end if
@@ -1579,15 +1579,15 @@ namespace rooibos
1579
1579
  return false
1580
1580
  end if
1581
1581
  try
1582
- if (type(node) = "roSGNode" and Rooibos.Common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and Rooibos.Common.isArray(subset))
1583
- isIgnoredFields = Rooibos.Common.isArray(ignoredFields)
1582
+ if (type(node) = "roSGNode" and rooibos.common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and rooibos.common.isArray(subset))
1583
+ isIgnoredFields = rooibos.common.isArray(ignoredFields)
1584
1584
  for each key in subset
1585
1585
  if key <> ""
1586
- if not isIgnoredFields or not Rooibos.Common.arrayContains(ignoredFields, key)
1586
+ if not isIgnoredFields or not rooibos.common.arrayContains(ignoredFields, key)
1587
1587
  subsetValue = subset[key]
1588
1588
  nodeValue = node[key]
1589
- if not Rooibos.Common.eqValues(nodeValue, subsetValue)
1590
- msg = key + ": Expected '" + Rooibos.Common.asString(subsetValue, true) + "', got '" + Rooibos.Common.asString(nodeValue, true) + "'"
1589
+ if not rooibos.common.eqValues(nodeValue, subsetValue)
1590
+ msg = key + ": Expected '" + rooibos.common.asString(subsetValue, true) + "', got '" + rooibos.common.asString(nodeValue, true) + "'"
1591
1591
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1592
1592
  return false
1593
1593
  end if
@@ -1626,8 +1626,8 @@ namespace rooibos
1626
1626
  return false
1627
1627
  end if
1628
1628
  try
1629
- if (type(node) = "roSGNode" and Rooibos.Common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and Rooibos.Common.isArray(subset))
1630
- isAA = Rooibos.Common.isAssociativeArray(subset)
1629
+ if (type(node) = "roSGNode" and rooibos.common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and rooibos.common.isArray(subset))
1630
+ isAA = rooibos.common.isAssociativeArray(subset)
1631
1631
  for each item in subset
1632
1632
  key = invalid
1633
1633
  value = item
@@ -1635,8 +1635,8 @@ namespace rooibos
1635
1635
  key = item
1636
1636
  value = item[key]
1637
1637
  end if
1638
- if Rooibos.Common.nodeContains(node, value)
1639
- msg = "Node has the '" + Rooibos.Common.asString(value, true) + "' value."
1638
+ if rooibos.common.nodeContains(node, value)
1639
+ msg = "Node has the '" + rooibos.common.asString(value, true) + "' value."
1640
1640
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1641
1641
  return false
1642
1642
  end if
@@ -1676,15 +1676,15 @@ namespace rooibos
1676
1676
  return false
1677
1677
  end if
1678
1678
  try
1679
- if Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isAssociativeArray(subset)
1680
- isIgnoredFields = Rooibos.Common.isArray(ignoredFields)
1679
+ if rooibos.common.isAssociativeArray(array) and rooibos.common.isAssociativeArray(subset)
1680
+ isIgnoredFields = rooibos.common.isArray(ignoredFields)
1681
1681
  for each key in subset
1682
1682
  if key <> ""
1683
- if not isIgnoredFields or not Rooibos.Common.arrayContains(ignoredFields, key)
1683
+ if not isIgnoredFields or not rooibos.common.arrayContains(ignoredFields, key)
1684
1684
  subsetValue = subset[key]
1685
1685
  arrayValue = array[key]
1686
- if not Rooibos.Common.eqValues(arrayValue, subsetValue)
1687
- msg = key + ": Expected '" + Rooibos.Common.asString(subsetValue, true) + "', got '" + Rooibos.Common.asString(arrayValue, true) + "'"
1686
+ if not rooibos.common.eqValues(arrayValue, subsetValue)
1687
+ msg = key + ": Expected '" + rooibos.common.asString(subsetValue, true) + "', got '" + rooibos.common.asString(arrayValue, true) + "'"
1688
1688
  m.currentResult.fail(msg, m.currentAssertLineNumber)
1689
1689
  return false
1690
1690
  end if
@@ -1725,7 +1725,10 @@ namespace rooibos
1725
1725
  ' * @returns {Object} - stub that was wired into the real method
1726
1726
  ' */
1727
1727
  function stub(target, methodName, returnValue = invalid, allowNonExistingMethods = false) as object
1728
- if type(target) <> "roAssociativeArray"
1728
+ if target = invalid and not rooibos.common.isFunction(methodName)
1729
+ m.fail("could not create Stub. Global function", methodName, ", is invalid")
1730
+ return {}
1731
+ else if type(target) <> "roAssociativeArray"
1729
1732
  m.fail("could not create Stub provided target was null")
1730
1733
  return {}
1731
1734
  end if
@@ -1746,18 +1749,22 @@ namespace rooibos
1746
1749
 
1747
1750
  fake = m.createFake(id, target, methodName, 1, invalid, returnValue)
1748
1751
  m.stubs[id] = fake
1749
- allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods
1750
- isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction"
1751
- if isMethodPresent or allowNonExisting
1752
- target[methodName] = m["StubCallback" + id]
1753
- target.__stubs = m.stubs
1754
-
1755
- ' FIXME: add a log setting for this - and add better detection so that stubs know that they are colliding/don't exist/have correct sigs
1756
- ' if not isMethodPresent
1757
- ' ? "WARNING - stubbing call " ; methodName; " which did not exist on target object"
1758
- ' end if
1752
+ if target.isGlobalCall = true
1753
+ rooibos.getMocksByFunctionName()[methodName] = fake
1759
1754
  else
1760
- ? "ERROR - could not create Stub : method not found "; target ; "." ; methodName
1755
+ allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods
1756
+ isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction"
1757
+ if isMethodPresent or allowNonExisting
1758
+ target[methodName] = m["StubCallback" + id]
1759
+ target.__stubs = m.stubs
1760
+
1761
+ ' FIXME: add a log setting for this - and add better detection so that stubs know that they are colliding/don't exist/have correct sigs
1762
+ ' if not isMethodPresent
1763
+ ' ? "WARNING - stubbing call " ; methodName; " which did not exist on target object"
1764
+ ' end if
1765
+ else
1766
+ ? "ERROR - could not create Stub : method not found "; target ; "." ; methodName
1767
+ end if
1761
1768
  end if
1762
1769
 
1763
1770
  return fake
@@ -1780,7 +1787,7 @@ namespace rooibos
1780
1787
  function _expectCalled(target, methodName, rootObject = invalid as dynamic, fullPath = invalid as dynamic, expectedArgs = invalid, returnValue = invalid as dynamic) as object
1781
1788
  try
1782
1789
  if type(target) <> "roAssociativeArray" and fullPath <> invalid
1783
- target = rooibos.Common.makePathStubbable(rootObject, fullPath)
1790
+ target = rooibos.common.makePathStubbable(rootObject, fullPath)
1784
1791
  end if
1785
1792
  return m.mock(target, methodName, 1, expectedArgs, returnValue, true)
1786
1793
  catch error
@@ -1798,7 +1805,7 @@ namespace rooibos
1798
1805
  function _stubCall(target, methodName, rootObject = invalid as dynamic, fullPath = invalid as dynamic, returnValue = invalid as dynamic) as object
1799
1806
  try
1800
1807
  if type(target) <> "roAssociativeArray" and fullPath <> invalid
1801
- target = rooibos.Common.makePathStubbable(rootObject, fullPath)
1808
+ target = rooibos.common.makePathStubbable(rootObject, fullPath)
1802
1809
  end if
1803
1810
  return m.stub(target, methodName, returnValue, true)
1804
1811
  catch error
@@ -1817,7 +1824,7 @@ namespace rooibos
1817
1824
  function _expectNotCalled(target, methodName, rootObject = invalid as dynamic, fullPath = invalid as dynamic) as object
1818
1825
  try
1819
1826
  if type(target) <> "roAssociativeArray" and fullPath <> invalid
1820
- target = rooibos.Common.makePathStubbable(rootObject, fullPath)
1827
+ target = rooibos.common.makePathStubbable(rootObject, fullPath)
1821
1828
  end if
1822
1829
  return m.mock(target, methodName, 0, invalid, invalid, true)
1823
1830
  catch error
@@ -1843,13 +1850,18 @@ namespace rooibos
1843
1850
  ' * @returns {Object} - mock that was wired into the real method
1844
1851
  ' */
1845
1852
  function expectOnce(target, methodName, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object
1846
- try
1853
+ 'HACK
1854
+ 'HACK
1855
+ 'HACK
1856
+ 'HACK
1857
+ 'HACK
1858
+ ' try
1847
1859
  return m.mock(target, methodName, 1, expectedArgs, returnValue, allowNonExistingMethods)
1848
- catch error
1860
+ ' catch error
1849
1861
  'bs:disable-next-line
1850
- m.currentResult.fail("Setting up mock failed: " + error.message, m.currentAssertLineNumber)
1851
- return false
1852
- end try
1862
+ ' m.currentResult.fail("Setting up mock failed: " + error.message, m.currentAssertLineNumber)
1863
+ ' return false
1864
+ ' end try
1853
1865
  return false
1854
1866
  end function
1855
1867
 
@@ -1943,19 +1955,20 @@ namespace rooibos
1943
1955
  function mock(target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object
1944
1956
  lineNumber = m.currentAssertLineNumber
1945
1957
  'check params
1946
- if not Rooibos.Common.isAssociativeArray(target)
1958
+
1959
+ if target <> invalid and not rooibos.common.isFunction(target) and not rooibos.common.isAssociativeArray(target)
1947
1960
  methodName = ""
1948
- m.mockFail(lineNumber, "", "mock args: target was not an AA")
1949
- else if not Rooibos.Common.isString(methodName)
1961
+ m.mockFail(lineNumber, "", "mock args: target should be an AA or in-scope Global function", methodName)
1962
+ else if not rooibos.common.isString(methodName)
1950
1963
  methodName = ""
1951
1964
  m.mockFail(lineNumber, "", "mock args: methodName was not a string")
1952
- else if not Rooibos.Common.isNumber(expectedInvocations)
1965
+ else if not rooibos.common.isNumber(expectedInvocations)
1953
1966
  m.mockFail(lineNumber, methodName, "mock args: expectedInvocations was not an int")
1954
- else if not Rooibos.Common.isArray(expectedArgs) and Rooibos.Common.isValid(expectedArgs)
1967
+ else if not rooibos.common.isArray(expectedArgs) and rooibos.common.isValid(expectedArgs)
1955
1968
  m.mockFail(lineNumber, methodName, "mock args: expectedArgs was not invalid or an array of args")
1956
- else if Rooibos.Common.isUndefined(expectedArgs)
1969
+ else if rooibos.common.isUndefined(expectedArgs)
1957
1970
  m.mockFail(lineNumber, methodName, "mock args: expectedArgs undefined")
1958
- else if Rooibos.Common.isUndefined(returnValue)
1971
+ else if rooibos.common.isUndefined(returnValue)
1959
1972
  m.mockFail(lineNumber, methodName, "mock args: returnValue undefined")
1960
1973
  end if
1961
1974
 
@@ -1968,9 +1981,15 @@ namespace rooibos
1968
1981
  m.__mockId = -1
1969
1982
  m.__mockTargetId = -1
1970
1983
  m.mocks = {}
1984
+ rooibos.resetMocksByFunctionName()
1971
1985
  end if
1972
1986
 
1973
1987
  fake = invalid
1988
+ if rooibos.common.isFunction(target)
1989
+ target = {
1990
+ isGlobalCall: true
1991
+ }
1992
+ end if
1974
1993
  if not target.doesExist("__rooibosTargetId")
1975
1994
  m.__mockTargetId++
1976
1995
  target["__rooibosTargetId"] = m.__mockTargetId
@@ -1979,7 +1998,7 @@ namespace rooibos
1979
1998
  for i = 0 to m.__mockId
1980
1999
  id = stri(i).trim()
1981
2000
  mock = m.mocks[id]
1982
- if mock <> invalid and mock.methodName = methodName and mock.target.__rooibosTargetId = target.__rooibosTargetId
2001
+ if mock <> invalid and mock.methodName = methodName and (mock.target.__rooibosTargetId = target.__rooibosTargetId or (mock.target.isGlobalCall = true and target.isGlobalCall = true))
1983
2002
  fake = mock
1984
2003
  fake.lineNumbers.push(lineNumber)
1985
2004
  exit for
@@ -1996,21 +2015,26 @@ namespace rooibos
1996
2015
 
1997
2016
  fake = m.createFake(id, target, methodName, expectedInvocations, expectedArgs, returnValue)
1998
2017
  m.mocks[id] = fake 'this will bind it to m
1999
- allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods
2000
- isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction"
2001
- if isMethodPresent or allowNonExisting
2002
- target[methodName] = m["MockCallback" + id]
2003
- target.__mocks = m.mocks
2004
-
2005
- if not isMethodPresent
2006
- ' ? "WARNING - mocking call " ; methodName; " which did not exist on target object"
2007
- end if
2018
+ if target.isGlobalCall = true
2019
+ rooibos.getMocksByFunctionName()[methodName] = fake
2008
2020
  else
2009
- ? "ERROR - could not create Mock : method not found "; target ; "." ; methodName
2021
+ allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods
2022
+ isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction"
2023
+ if isMethodPresent or allowNonExisting
2024
+ target[methodName] = m["MockCallback" + id]
2025
+ target.__mocks = m.mocks
2026
+
2027
+ if not isMethodPresent
2028
+ ' ? "WARNING - mocking call " ; methodName; " which did not exist on target object"
2029
+ end if
2030
+ else
2031
+ ? "ERROR - could not create Mock : method not found "; target ; "." ; methodName
2032
+ end if
2010
2033
  end if
2011
2034
  else
2012
2035
  m.combineFakes(fake, m.createFake(id, target, methodName, expectedInvocations, expectedArgs, returnValue))
2013
2036
  end if
2037
+
2014
2038
  return fake
2015
2039
  end function
2016
2040
 
@@ -2030,22 +2054,23 @@ namespace rooibos
2030
2054
  function createFake(id, target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid) as object
2031
2055
  expectedArgsValues = []
2032
2056
  lineNumber = m.currentAssertLineNumber
2033
- hasArgs = Rooibos.Common.isArray(expectedArgs)
2057
+ hasArgs = rooibos.common.isArray(expectedArgs)
2034
2058
  defaultValue = m.ignoreValue
2035
2059
  if hasArgs
2036
2060
  defaultValue = m.invalidValue
2037
2061
  else
2038
2062
  expectedArgs = []
2039
2063
  end if
2064
+
2040
2065
  lineNumbers = [lineNumber]
2041
2066
 
2042
2067
  for i = 0 to 9
2043
2068
  if hasArgs and expectedArgs.count() > i
2044
2069
  'guard against bad values
2045
2070
  value = expectedArgs[i]
2046
- if not Rooibos.Common.isUndefined(value)
2047
- if Rooibos.Common.isAssociativeArray(value) and Rooibos.Common.isValid(value.matcher)
2048
- if not Rooibos.Common.isFunction(value.matcher)
2071
+ if not rooibos.common.isUndefined(value)
2072
+ if rooibos.common.isAssociativeArray(value) and rooibos.common.isValid(value.matcher)
2073
+ if not rooibos.common.isFunction(value.matcher)
2049
2074
  ? "[ERROR] you have specified a matching function; but it is not in scope!"
2050
2075
  expectedArgsValues.push("#ERR-OUT_OF_SCOPE_MATCHER!")
2051
2076
  else
@@ -2158,7 +2183,7 @@ namespace rooibos
2158
2183
  ' * @description Will check all mocks that have been created to ensure they were invoked the expected amount of times, with the expected args.
2159
2184
  ' */
2160
2185
  function assertMocks() as void
2161
- if m.__mockId = invalid or not Rooibos.Common.isAssociativeArray(m.mocks)
2186
+ if m.__mockId = invalid or not rooibos.common.isAssociativeArray(m.mocks)
2162
2187
  return
2163
2188
  end if
2164
2189
 
@@ -2169,8 +2194,8 @@ namespace rooibos
2169
2194
  m.mockFail(mock.lineNumbers[0], methodName, "Wrong number of calls. (" + stri(mock.invocations).trim() + " / " + stri(mock.expectedInvocations).trim() + ")")
2170
2195
  m.cleanMocks()
2171
2196
  return
2172
- else if mock.expectedInvocations > 0 and (Rooibos.Common.isArray(mock.expectedArgs) or (type(mock.expectedArgs) = "roAssociativeArray" and Rooibos.Common.isArray(mock.expectedArgs.multiInvoke)))
2173
- isMultiArgsSupported = type(mock.expectedArgs) = "roAssociativeArray" and Rooibos.Common.isArray(mock.expectedArgs.multiInvoke)
2197
+ else if mock.expectedInvocations > 0 and (rooibos.common.isArray(mock.expectedArgs) or (type(mock.expectedArgs) = "roAssociativeArray" and rooibos.common.isArray(mock.expectedArgs.multiInvoke)))
2198
+ isMultiArgsSupported = type(mock.expectedArgs) = "roAssociativeArray" and rooibos.common.isArray(mock.expectedArgs.multiInvoke)
2174
2199
 
2175
2200
  for invocationIndex = 0 to mock.invocations - 1
2176
2201
  invokedArgs = mock.allInvokedArgs[invocationIndex]
@@ -2182,25 +2207,25 @@ namespace rooibos
2182
2207
  for i = 0 to expectedArgs.count() - 1
2183
2208
  value = invokedArgs[i]
2184
2209
  expected = expectedArgs[i]
2185
- didNotExpectArg = Rooibos.Common.isString(expected) and expected = m.invalidValue
2210
+ didNotExpectArg = rooibos.common.isString(expected) and expected = m.invalidValue
2186
2211
  if didNotExpectArg
2187
2212
  expected = invalid
2188
2213
  end if
2189
2214
 
2190
- isUsingMatcher = Rooibos.Common.isAssociativeArray(expected) and Rooibos.Common.isFunction(expected.matcher)
2215
+ isUsingMatcher = rooibos.common.isAssociativeArray(expected) and rooibos.common.isFunction(expected.matcher)
2191
2216
 
2192
2217
  if isUsingMatcher
2193
2218
  if not expected.matcher(value)
2194
- m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to match matching function '" + Rooibos.Common.asString(expected.matcher) + "' got '" + Rooibos.Common.asString(value, true) + "')")
2219
+ m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to match matching function '" + rooibos.common.asString(expected.matcher) + "' got '" + rooibos.common.asString(value, true) + "')")
2195
2220
  m.cleanMocks()
2196
2221
  end if
2197
2222
  else
2198
- if not (Rooibos.Common.isString(expected) and expected = m.ignoreValue) and not Rooibos.Common.eqValues(value, expected)
2223
+ if not (rooibos.common.isString(expected) and expected = m.ignoreValue) and not rooibos.common.eqValues(value, expected)
2199
2224
  if expected = invalid
2200
2225
  expected = "[INVALID]"
2201
2226
  end if
2202
2227
 
2203
- m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to be '" + Rooibos.Common.asString(expected, true) + "' got '" + Rooibos.Common.asString(value, true) + "')")
2228
+ m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to be '" + rooibos.common.asString(expected, true) + "' got '" + rooibos.common.asString(value, true) + "')")
2204
2229
  m.cleanMocks()
2205
2230
  return
2206
2231
  end if
@@ -2229,6 +2254,7 @@ namespace rooibos
2229
2254
  mock.target.__mocks = invalid
2230
2255
  end for
2231
2256
  m.mocks = invalid
2257
+ rooibos.resetMocksByFunctionName()
2232
2258
  end function
2233
2259
 
2234
2260
  ' /**
@@ -2247,6 +2273,7 @@ namespace rooibos
2247
2273
  stub.target.__stubs = invalid
2248
2274
  end for
2249
2275
  m.stubs = invalid
2276
+ rooibos.resetMocksByFunctionName()
2250
2277
  end function
2251
2278
 
2252
2279
 
@@ -2699,4 +2726,23 @@ namespace rooibos
2699
2726
  ' ? "++++++++ TEST TIMED OUT"
2700
2727
  m.testRunner.currentTestSuite.failBecauseOfTimeOut()
2701
2728
  end function
2729
+
2730
+ function getMocksByFunctionName()
2731
+ if m._rMocksByFunctionName = invalid
2732
+ m._rMocksByFunctionName = {}
2733
+ end if
2734
+ return m._rMocksByFunctionName
2735
+ end function
2736
+
2737
+ function resetMocksByFunctionName()
2738
+ m._rMocksByFunctionName = invalid
2739
+ end function
2740
+
2741
+ function getMockForFunction(functionName as string)
2742
+ return rooibos.getMocksByFunctionName()[functionName]
2743
+ end function
2744
+
2745
+ function isFunctionMocked(functionName as string)
2746
+ return rooibos.getMockForFunction(functionName) <> invalid
2747
+ end function
2702
2748
  end namespace