Qore QUnit Module Reference  0.3.2
QUnit.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file QUnit.qm Qore user module for automatic testing
3 
4 
5 
6 
7 
8 
149 namespace QUnit {}
151 
154 
155 public:
156  public :
157  string m_type;
158  *string m_subType;
159  auto m_value;
160 
161 public:
162  constructor(string type);
163 
164  constructor(string type, string subType);
165 
166  // test
167  abstract bool equals(AbstractTestResult r); abstract string toString();};
168 
171 
172 public:
173  constructor() ;
174 
175 
177  bool equals(QUnit::AbstractTestResult r);
178 
179  string toString();
180 };
181 
184 
185 public:
186  private :
187  *string m_detail;
188 
189 public:
190 
192  constructor() ;
193 
194 
196  constructor(string s) ;
197 
198 
200  bool equals(QUnit::AbstractTestResult r);
201 
202  string toString();
203 };
204 
207 
208 public:
209  constructor(auto value) ;
210 
211 
213  bool equals(QUnit::AbstractTestResult r);
214 
215  string toString();
216 };
217 
220 
221 public:
222  constructor(hash value) ;
223 
224 
225  bool equals(QUnit::AbstractTestResult r);
226 
227  string toString();
228 };
229 
232 
233 public:
234  public :
237 
238 public:
239 
241 
243  constructor(string exceptionType) ;
244 
245 
247 
248 private:
249  constructor(string exceptionType, string subType) ;
250 public:
251 
252 
254  bool equals(QUnit::AbstractTestResult r);
255 
257  string toString();
258 };
259 
262 
263 public:
264  private :
265  string m_exceptionDetail;
266 
267 public:
268 
270 
273  constructor(string exceptionType, string exceptionDetail) ;
274 
275 
277  bool equals(QUnit::AbstractTestResult r);
278 
279  string toString();
280 
281  string getDetail();
282 
283 };
284 
287 
288 public:
289  private :
290  string m_exceptionRegexp;
291 
292 public:
293 
294  constructor(string exceptionType, string exceptionRegexp) ;
295 
296 
298  bool equals(QUnit::AbstractTestResult r);
299 
300  string toString();
301 };
302 
305 
306 public:
307  constructor(string exceptionType, string exceptionSubstring) ;
308 
309 
310  string toString();
311 };
312 
315 
316 public:
317  private :
319  string m_name;
320 
322  code m_code;
323 
325  *list<auto> m_args;
326 
328  int num_asserts = 0;
329 
331  int num_asserts_ok = 0;
332 
334  int num_asserts_skip = 0;
335 
336 public:
337 
339  constructor(string name, code code, *softlist<auto> args);
340 
341 
343  run(QUnit::Test test);
344 
345 
346  static list<string> getStackList(list stack, bool ok = False);
347 
348  static string getPos(hash ex);
349 
351  checkException(QUnit::Test test, hash e);
352 
353 
355  string getName();
356 
357 
358  incAssertions();
359 
360 
361  incAssertionsOk();
362 
363 
364  incAssertionsSkip();
365 
366 
367  int getAssertionCount();
368 
369 
370  int getAssertionOkCount();
371 
372 
373  int getAssertionSkipCount();
374 
375 
376  setupThread();
377 
378 
379  restoreThread();
380 
381 
383  rename(string n_name);
384 
385 };
386 
389 
390 public:
391  private :
392  const PLAINQUIET = 0;
393  const PLAIN = 1;
394  const JUNIT = 2;
395 
396  const OUT_TYPES = (
397  "plainquiet" : PLAINQUIET,
398  "plain" : PLAIN,
399  "junit" : JUNIT,
400  );
401 
402  const RESULT_TYPE_DESCRIPTION = (
403  TEST_SUCCESS : ("desc": "Success", "junittag" : NOTHING), // Success does not have a junit child tag
404  TEST_FAILURE : ("desc": "FAILURE", "junittag" : "failure"),
405  TEST_ERROR : ("desc": "ERROR", "junittag" : "error"),
406  TEST_SKIPPED : ("desc": "Skipped", "junittag" : "skipped"),
407  );
408 
410  const OffsetColumn = 20;
411 
414 
415  list m_results = ();
416  int m_output;
417  *string m_comment;
418 
420 
425 
427  string m_name;
429  string m_version;
430 
432  int num_asserts = 0;
433 
435  int num_asserts_ok = 0;
436 
438  int num_asserts_skip = 0;
439 
440 public:
441 
442  public :
444  const Opts = (
445  "help" : "h,help",
446  "verbose" : "v,verbose:i+",
447  "quiet" : "q,quiet",
448  "format" : "format=s",
449  );
450 
451  const TEST_SUCCESS = 0;
452  const TEST_FAILURE = 1;
453  const TEST_ERROR = 2;
454  const TEST_SKIPPED = 3;
455 
456 public:
457 
458 
459 private:
460  printOption(string left, string right, int offset = OffsetColumn);
461 public:
462 
463 
464 
465 private:
466  usageIntern(int offset = OffsetColumn);
467 public:
468 
469 
470 
471 private:
472  usage();
473 public:
474 
475 
476 
477 private:
478  processOptions(reference<list<string>> p_argv);
479 public:
480 
481 
483 
488  constructor(string name, string version, *reference<list<string>> p_argv, hash opts = Opts);
489 
490 
491 
492 private:
493  callPrinterFunction(string type, *softlist<auto> args);
494 public:
495 
496 
497 
498 private:
499  printHeader() { callPrinterFunction("header"); } printSummary() { callPrinterFunction("summary"); } printTestReport(hash testcase) { callPrinterFunction("testreport", testcase); }
500  printPlaintextHeader();
501 
502  printPlaintextSummary();
503 
504  printPlaintextOneTest(hash testcase);
505 
506  printJunitSummary();
507 
509  int errors();
510 
511 
513  int skipped();
514 
515 
517  int testCount();
518 
519 
521  addTestResult(TestCase tc, int success, *string error, *string pos, *string detail);
522 
523 };
524 
527 
528 public:
529  private :
531  list<TestCase> testCases();
532 
533  static QUnit::TestResultSuccess RESULT_SUCCESS = new QUnit::TestResultSuccess();
534  static QUnit::TestResultFailure RESULT_FAILURE = new QUnit::TestResultFailure();
535 
536 public:
537 
538  private:internal {
540  const QUC_EQ = "eq";
542  const QUC_NEQ = "neq";
544  const QUC_GT = "gt";
546  const QUC_GE = "ge";
548  const QUC_LT = "lt";
550  const QUC_LE = "le";
552  const QUC_RE = "re";
554  const QUC_NRE = "nre";
555 
557  const QUC_Map = (
558  QUC_EQ: NOTHING,
559  QUC_NEQ: "Not Equal",
560  QUC_GT: "Greater Than",
561  QUC_GE: "Greater Than Or Equal To",
562  QUC_LT: "Less Than",
563  QUC_LE: "Less Than Or Equal To",
564  QUC_RE: "Regular Expression Match",
565  QUC_NRE: "Negative Regular Expression Match",
566  );
567 
569  const DEFAULT_EPSILON = 0.0000000001;
570  }
571 
573  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
574 
575 
578 
581 
583  setUp() {}
584 
586  tearDown() {}
587 
589  *string getEnv(string key, *string def);
590 
591 
593 
602  addTestCase(string name, code call, *softlist<auto> args);
603 
604 
606 
613  addTestCase(QUnit::TestCase tc);
614 
615 
616  string escapeSpecialChars(string str);
617 
618  bool diffInSpecialCharsOnly(string a, string b);
619 
621  string printUnexpectedData(auto exp, auto act, *bool neg, *bool soft_comparisons, *string comparitor);
622 
623  string shorten(auto value);
624 
625  compare(auto v1, auto v2, reference<list<string>> out, string path, *bool soft_comparisons);
626 
627  compareHashes(hash h1, hash h2, reference<list<string>> out, string path = "", *bool soft_comparisons);
628 
629  compareLists(list<auto> l1, list<auto> l2, reference<list<string>> out, string path = "", *bool soft_comparisons);
630 
631 //######## Assertions & test control functions
632 
634 
647  auto testAssertionValue(*string name, auto actual, auto expected);
648 
650 
660  auto testAssertionValue(*string name, number actual, number expected, number epsilon = DEFAULT_EPSILON);
661 
663 
673  auto testAssertionValue(*string name, float actual, float expected, float epsilon = DEFAULT_EPSILON);
675 
684  assertRegex(string regex_pattern, string actual, *string name);
685 
687 
696  assertNRegex(string regex_pattern, string actual, *string name);
697 
699 
707  assertNothing(auto actual, *string name);
708 
710 
719  assertEqSoft(auto expected, auto actual, *string name);
720 
722 
731  assertNeqSoft(auto expected, auto actual, *string name);
732 
734 
743  assertEq(auto expected, auto actual, *string name);
744 
746 
755  assertNeq(auto expected, auto actual, *string name);
756 
758 
768  assertFloatEq(float expected, float actual, float epsilon = DEFAULT_EPSILON, *string name);
769 
771 
781  assertNumberEq(number expected, number actual, number epsilon = DEFAULT_EPSILON, *string name);
782 
784 
793  assertGtSoft(auto expected, auto actual, *string name);
794 
796 
805  assertGt(auto expected, auto actual, *string name);
806 
808 
817  assertGeSoft(auto expected, auto actual, *string name);
818 
820 
829  assertGe(auto expected, auto actual, *string name);
830 
832 
841  assertLtSoft(auto expected, auto actual, *string name);
842 
844 
853  assertLt(auto expected, auto actual, *string name);
854 
856 
865  assertLeSoft(auto expected, auto actual, *string name);
866 
868 
877  assertLe(auto expected, auto actual, *string name);
878 
880  assertionOk(*string name);
881 
883 
891  assertTrue(auto actual, *string name);
892 
894 
902  assertFalse(auto actual, *string name);
903 
905 
916  assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist<auto> args, *string name);
917 
919 
929  assertThrows(string expectedErr, code theCode, *softlist<auto> args, *string name);
930 
932 
940  assertSkip (*string name);
941 
943  TestCase getTestCase(string meth);
944 
945 
947 
954  fail(*string msg);
955 
957 
964  testNullAssertion(string name, code condition, *softlist<auto> args);
965 
967 
975  auto testAssertion(string name, code condition, *softlist<auto> args, int expectedResultValue);
976 
978 
986  auto testAssertion(string name, code condition, *softlist<auto> args, float expectedResultValue);
987 
989 
997  auto testAssertion(string name, code condition, *softlist<auto> args, number expectedResultValue);
998 
1000 
1008  auto testAssertion(string name, code condition, *softlist<auto> args, bool expectedResultValue);
1009 
1011 
1019  auto testAssertion(string name, code condition, *softlist<auto> args, string expectedResultValue);
1020 
1022 
1030  auto testAssertion(string name, code condition, *softlist<auto> args, date expectedResultValue);
1031 
1033 
1041  auto testAssertion(string name, code condition, *softlist<auto> args, binary expectedResultValue);
1042 
1044 
1052  auto testAssertion(string name, code condition, *softlist<auto> args, hash expectedResultValue);
1053 
1055 
1063  auto testAssertion(string name, code condition, *softlist<auto> args, list expectedResultValue);
1064 
1066 
1074  auto testAssertion(string name, code condition, *softlist<auto> args, QUnit::AbstractTestResult expectedResult = new QUnit::TestResultSuccess());
1075 
1076  auto testAssertionIntern(TestCase tc, string name, QUnit::AbstractTestResult actualResult, QUnit::AbstractTestResult expectedResult, auto ret, *string pos);
1077 
1079 
1082  testSkip(string reason);
1083 
1084 //######## Test conditions passable to test assertions
1085 
1087 
1093  bool equals(auto a, auto b);
1094 
1095 
1097 
1103  bool notEquals(auto a, auto b);
1104 
1105 
1107 
1113  bool regexpMatches(string s, string regexp);
1114 
1115 
1117 
1123  bool equalsIterated(AbstractIterator a, AbstractIterator b);
1124 
1125 
1126 //######## Main function and test running helpers
1127 
1129  int main();
1130 
1131 
1133  static string getAssertionName(*string name);
1134 };
1135 
1138 
1139 public:
1140  private :
1141  *string m_testedFile;
1142  Program m_child;
1143  *hash m_modules;
1144 
1145  static bool instantiated = False;
1146 
1147 public:
1148 
1149  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
1150 
1151 
1153  setScriptPath(*string testedFile);
1154 
1155 
1157  setUp() { }
1158  tearDown() { }
1159 
1160  Program createInjectedProgram();
1161 
1162  abstract performInjections(Program p);
1163  abstract performModuleInjections();
1164 
1165  injectIntoModule(string module);
1166 
1167  destructor();
1168 
1169 
1170  int main();
1171 
1172 };
1173 
1174 class QUnit::DependencyInjectedTestRunner : public QUnit::Test {
1175 
1176 public:
1177  setScriptPath(*string testedFile) {} injectIntoModule(string module) {}
1178  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
1179 
1180 };
nothing rename(string old_path, string new_path)
date date(date dt)
Class representing Exception of a particular type with a particular detail message.
Definition: QUnit.qm.dox.h:261
Class representing any non-boolean value.
Definition: QUnit.qm.dox.h:206
number exp(number n)
string m_name
the name of the test case
Definition: QUnit.qm.dox.h:319
A class representing a test with injected dependencies.
Definition: QUnit.qm.dox.h:1137
Class representing a partial match of a hash value. Common keys have to be identical.
Definition: QUnit.qm.dox.h:219
tearDown()
Prototype function for cleaning up test environemnt. It will be called after each test has executed...
Definition: QUnit.qm.dox.h:586
Class representing Exception of a particular type and substring for detail.
Definition: QUnit.qm.dox.h:304
An abstract class representing test result interface.
Definition: QUnit.qm.dox.h:153
Class representing Exception of a particular type.
Definition: QUnit.qm.dox.h:231
number number(softnumber n)
binary binary()
Class representing boolean True.
Definition: QUnit.qm.dox.h:170
const False
Class containing the configuration for a test case.
Definition: QUnit.qm.dox.h:314
string m_exceptionType
corresponds to the "err" key of ExceptionInfo (the first value of a throw statement) ...
Definition: QUnit.qm.dox.h:236
setUp()
A prototype function.
Definition: QUnit.qm.dox.h:1157
list list(...)
the main namespace for all public definitions in the QUnit module
Definition: QUnit.qm.dox.h:150
hash m_options
the result of parsing command-line options with Qore::GetOpt::parse2()
Definition: QUnit.qm.dox.h:424
Base class for collecting test results and reporting.
Definition: QUnit.qm.dox.h:388
hash m_printMethods
A map of print methods, categorised into three types: header, summary, testreport.
Definition: QUnit.qm.dox.h:413
globalTearDown()
global tear down; will be called once after all tests are run
Definition: QUnit.qm.dox.h:580
string m_name
test case name
Definition: QUnit.qm.dox.h:427
string m_version
test case version
Definition: QUnit.qm.dox.h:429
Class representing Exception of a particular type and matching regexp for detail. ...
Definition: QUnit.qm.dox.h:286
const NOTHING
string type(auto arg)
globalSetUp()
global setup; will be called once before tests are run
Definition: QUnit.qm.dox.h:577
setUp()
Prototype function for setting up test environment. It will be called for each test individually...
Definition: QUnit.qm.dox.h:583
code m_code
the body of the test case
Definition: QUnit.qm.dox.h:322
Class representing test function failure, both unspecific and with detail.
Definition: QUnit.qm.dox.h:183
hash hash(object obj)
*list< auto > m_args
arguments to the above callable object
Definition: QUnit.qm.dox.h:325
Base class representing a simple test, implements an implicit main() function and all utility functio...
Definition: QUnit.qm.dox.h:526