Qore QUnit Module Reference  0.3.3
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 
152 namespace QUnit {}
154 
157 
158 public:
159  public :
160  string m_type;
161  *string m_subType;
162  auto m_value;
163 
164 public:
165  constructor(string type);
166 
167  constructor(string type, string subType);
168 
169  // test
170  abstract bool equals(AbstractTestResult r); abstract string toString();};
171 
174 
175 public:
176  constructor() ;
177 
178 
180  bool equals(QUnit::AbstractTestResult r);
181 
182  string toString();
183 };
184 
187 
188 public:
189  private :
190  *string m_detail;
191 
192 public:
193 
195  constructor() ;
196 
197 
199  constructor(string s) ;
200 
201 
203  bool equals(QUnit::AbstractTestResult r);
204 
205  string toString();
206 };
207 
210 
211 public:
212  constructor(auto value) ;
213 
214 
216  bool equals(QUnit::AbstractTestResult r);
217 
218  string toString();
219 };
220 
223 
224 public:
225  constructor(hash value) ;
226 
227 
228  bool equals(QUnit::AbstractTestResult r);
229 
230  string toString();
231 };
232 
235 
236 public:
237  public :
240 
241 public:
242 
244 
246  constructor(string exceptionType) ;
247 
248 
250 
251 private:
252  constructor(string exceptionType, string subType) ;
253 public:
254 
255 
257  bool equals(QUnit::AbstractTestResult r);
258 
260  string toString();
261 };
262 
265 
266 public:
267  private :
268  string m_exceptionDetail;
269 
270 public:
271 
273 
276  constructor(string exceptionType, string exceptionDetail) ;
277 
278 
280  bool equals(QUnit::AbstractTestResult r);
281 
282  string toString();
283 
284  string getDetail();
285 
286 };
287 
290 
291 public:
292  private :
293  string m_exceptionRegexp;
294 
295 public:
296 
297  constructor(string exceptionType, string exceptionRegexp) ;
298 
299 
301  bool equals(QUnit::AbstractTestResult r);
302 
303  string toString();
304 };
305 
308 
309 public:
310  constructor(string exceptionType, string exceptionSubstring) ;
311 
312 
313  string toString();
314 };
315 
318 
319 public:
320  private :
322  string m_name;
323 
325  code m_code;
326 
328  *list<auto> m_args;
329 
331  int num_asserts = 0;
332 
334  int num_asserts_ok = 0;
335 
337  int num_asserts_skip = 0;
338 
339 public:
340 
342  constructor(string name, code code, *softlist<auto> args);
343 
344 
346  run(QUnit::Test test);
347 
348 
349  static list<string> getStackList(list stack, bool ok = False);
350 
351  static string getPos(hash ex);
352 
354  checkException(QUnit::Test test, hash e);
355 
356 
358  string getName();
359 
360 
361  incAssertions();
362 
363 
364  incAssertionsOk();
365 
366 
367  incAssertionsSkip();
368 
369 
370  int getAssertionCount();
371 
372 
373  int getAssertionOkCount();
374 
375 
376  int getAssertionSkipCount();
377 
378 
379  setupThread();
380 
381 
382  restoreThread();
383 
384 
386  rename(string n_name);
387 
388 };
389 
392 
393 public:
394  private :
395  const PLAINQUIET = 0;
396  const PLAIN = 1;
397  const JUNIT = 2;
398 
399  const OUT_TYPES = (
400  "plainquiet" : PLAINQUIET,
401  "plain" : PLAIN,
402  "junit" : JUNIT,
403  );
404 
405  const RESULT_TYPE_DESCRIPTION = (
406  TEST_SUCCESS : ("desc": "Success", "junittag" : NOTHING), // Success does not have a junit child tag
407  TEST_FAILURE : ("desc": "FAILURE", "junittag" : "failure"),
408  TEST_ERROR : ("desc": "ERROR", "junittag" : "error"),
409  TEST_SKIPPED : ("desc": "Skipped", "junittag" : "skipped"),
410  );
411 
413  const OffsetColumn = 20;
414 
417 
418  list m_results = ();
419  int m_output;
420  *string m_comment;
421 
423 
428 
430  string m_name;
432  string m_version;
433 
435  int num_asserts = 0;
436 
438  int num_asserts_ok = 0;
439 
441  int num_asserts_skip = 0;
442 
443 public:
444 
445  public :
447  const Opts = (
448  "help" : "h,help",
449  "verbose" : "v,verbose:i+",
450  "quiet" : "q,quiet",
451  "format" : "format=s",
452  );
453 
454  const TEST_SUCCESS = 0;
455  const TEST_FAILURE = 1;
456  const TEST_ERROR = 2;
457  const TEST_SKIPPED = 3;
458 
459 public:
460 
461 
462 private:
463  printOption(string left, string right, int offset = OffsetColumn);
464 public:
465 
466 
467 
468 private:
469  usageIntern(int offset = OffsetColumn);
470 public:
471 
472 
473 
474 private:
475  usage();
476 public:
477 
478 
479 
480 private:
481  processOptions(reference<list<string>> p_argv);
482 public:
483 
484 
486 
491  constructor(string name, string version, *reference<list<string>> p_argv, hash opts = Opts);
492 
493 
494 
495 private:
496  callPrinterFunction(string type, *softlist<auto> args);
497 public:
498 
499 
500 
501 private:
502  printHeader() { callPrinterFunction("header"); } printSummary() { callPrinterFunction("summary"); } printTestReport(hash testcase) { callPrinterFunction("testreport", testcase); }
503  printPlaintextHeader();
504 
505  printPlaintextSummary();
506 
507  printPlaintextOneTest(hash testcase);
508 
509  printJunitSummary();
510 
512  int errors();
513 
514 
516  int skipped();
517 
518 
520  int testCount();
521 
522 
524  addTestResult(TestCase tc, int success, *string error, *string pos, *string detail);
525 
526 };
527 
530 
531 public:
532  private :
534  list<TestCase> testCases();
535 
536  static QUnit::TestResultSuccess RESULT_SUCCESS = new QUnit::TestResultSuccess();
537  static QUnit::TestResultFailure RESULT_FAILURE = new QUnit::TestResultFailure();
538 
539 public:
540 
541  private:internal {
543  const QUC_EQ = "eq";
545  const QUC_NEQ = "neq";
547  const QUC_GT = "gt";
549  const QUC_GE = "ge";
551  const QUC_LT = "lt";
553  const QUC_LE = "le";
555  const QUC_RE = "re";
557  const QUC_NRE = "nre";
558 
560  const QUC_Map = (
561  QUC_EQ: NOTHING,
562  QUC_NEQ: "Not Equal",
563  QUC_GT: "Greater Than",
564  QUC_GE: "Greater Than Or Equal To",
565  QUC_LT: "Less Than",
566  QUC_LE: "Less Than Or Equal To",
567  QUC_RE: "Regular Expression Match",
568  QUC_NRE: "Negative Regular Expression Match",
569  );
570 
572  const DEFAULT_EPSILON = 0.0000000001;
573  }
574 
576  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
577 
578 
581 
584 
586  setUp() {}
587 
589  tearDown() {}
590 
592  *string getEnv(string key, *string def);
593 
594 
596 
605  addTestCase(string name, code call, *softlist<auto> args);
606 
607 
609 
616  addTestCase(QUnit::TestCase tc);
617 
618 
619  string escapeSpecialChars(string str);
620 
621  bool diffInSpecialCharsOnly(string a, string b);
622 
624  string printUnexpectedData(auto exp, auto act, *bool neg, *bool soft_comparisons, *string comparitor);
625 
626  string shorten(auto value);
627 
628  compare(auto v1, auto v2, reference<list<string>> out, string path, *bool soft_comparisons);
629 
630  compareHashes(hash h1, hash h2, reference<list<string>> out, string path = "", *bool soft_comparisons);
631 
632  compareLists(list<auto> l1, list<auto> l2, reference<list<string>> out, string path = "", *bool soft_comparisons);
633 
634 //######## Assertions & test control functions
635 
637 
650  auto testAssertionValue(*string name, auto actual, auto expected);
651 
653 
663  auto testAssertionValue(*string name, number actual, number expected, number epsilon = DEFAULT_EPSILON);
664 
666 
676  auto testAssertionValue(*string name, float actual, float expected, float epsilon = DEFAULT_EPSILON);
678 
687  assertRegex(string regex_pattern, string actual, *string name);
688 
690 
699  assertNRegex(string regex_pattern, string actual, *string name);
700 
702 
710  assertNothing(auto actual, *string name);
711 
713 
722  assertEqSoft(auto expected, auto actual, *string name);
723 
725 
734  assertNeqSoft(auto expected, auto actual, *string name);
735 
737 
746  assertEq(auto expected, auto actual, *string name);
747 
749 
758  assertNeq(auto expected, auto actual, *string name);
759 
761 
771  assertFloatEq(float expected, float actual, float epsilon = DEFAULT_EPSILON, *string name);
772 
774 
784  assertNumberEq(number expected, number actual, number epsilon = DEFAULT_EPSILON, *string name);
785 
787 
796  assertGtSoft(auto expected, auto actual, *string name);
797 
799 
808  assertGt(auto expected, auto actual, *string name);
809 
811 
820  assertGeSoft(auto expected, auto actual, *string name);
821 
823 
832  assertGe(auto expected, auto actual, *string name);
833 
835 
844  assertLtSoft(auto expected, auto actual, *string name);
845 
847 
856  assertLt(auto expected, auto actual, *string name);
857 
859 
868  assertLeSoft(auto expected, auto actual, *string name);
869 
871 
880  assertLe(auto expected, auto actual, *string name);
881 
883  assertionOk(*string name);
884 
886 
894  assertTrue(auto actual, *string name);
895 
897 
905  assertFalse(auto actual, *string name);
906 
908 
919  assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist<auto> args, *string name);
920 
922 
932  assertThrows(string expectedErr, code theCode, *softlist<auto> args, *string name);
933 
935 
943  assertSkip (*string name);
944 
946  TestCase getTestCase(string meth);
947 
948 
950 
957  fail(*string msg);
958 
960 
967  testNullAssertion(string name, code condition, *softlist<auto> args);
968 
970 
978  auto testAssertion(string name, code condition, *softlist<auto> args, int expectedResultValue);
979 
981 
989  auto testAssertion(string name, code condition, *softlist<auto> args, float expectedResultValue);
990 
992 
1000  auto testAssertion(string name, code condition, *softlist<auto> args, number expectedResultValue);
1001 
1003 
1011  auto testAssertion(string name, code condition, *softlist<auto> args, bool expectedResultValue);
1012 
1014 
1022  auto testAssertion(string name, code condition, *softlist<auto> args, string expectedResultValue);
1023 
1025 
1033  auto testAssertion(string name, code condition, *softlist<auto> args, date expectedResultValue);
1034 
1036 
1044  auto testAssertion(string name, code condition, *softlist<auto> args, binary expectedResultValue);
1045 
1047 
1055  auto testAssertion(string name, code condition, *softlist<auto> args, hash expectedResultValue);
1056 
1058 
1066  auto testAssertion(string name, code condition, *softlist<auto> args, list expectedResultValue);
1067 
1069 
1077  auto testAssertion(string name, code condition, *softlist<auto> args, QUnit::AbstractTestResult expectedResult = new QUnit::TestResultSuccess());
1078 
1079  auto testAssertionIntern(TestCase tc, string name, QUnit::AbstractTestResult actualResult, QUnit::AbstractTestResult expectedResult, auto ret, *string pos);
1080 
1082 
1085  testSkip(string reason);
1086 
1087 //######## Test conditions passable to test assertions
1088 
1090 
1096  bool equals(auto a, auto b);
1097 
1098 
1100 
1106  bool notEquals(auto a, auto b);
1107 
1108 
1110 
1116  bool regexpMatches(string s, string regexp);
1117 
1118 
1120 
1126  bool equalsIterated(AbstractIterator a, AbstractIterator b);
1127 
1128 
1129 //######## Main function and test running helpers
1130 
1132  int main();
1133 
1134 
1136  static string getAssertionName(*string name);
1137 };
1138 
1141 
1142 public:
1143  private :
1144  *string m_testedFile;
1145  Program m_child;
1146  *hash m_modules;
1147 
1148  static bool instantiated = False;
1149 
1150 public:
1151 
1152  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
1153 
1154 
1156  setScriptPath(*string testedFile);
1157 
1158 
1160  setUp() { }
1161  tearDown() { }
1162 
1163  Program createInjectedProgram();
1164 
1165  abstract performInjections(Program p);
1166  abstract performModuleInjections();
1167 
1168  injectIntoModule(string module);
1169 
1170  destructor();
1171 
1172 
1173  int main();
1174 
1175 };
1176 
1177 class QUnit::DependencyInjectedTestRunner : public QUnit::Test {
1178 
1179 public:
1180  setScriptPath(*string testedFile) {} injectIntoModule(string module) {}
1181  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
1182 
1183 };
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:264
Class representing any non-boolean value.
Definition: QUnit.qm.dox.h:209
number exp(number n)
string m_name
the name of the test case
Definition: QUnit.qm.dox.h:322
A class representing a test with injected dependencies.
Definition: QUnit.qm.dox.h:1140
Class representing a partial match of a hash value. Common keys have to be identical.
Definition: QUnit.qm.dox.h:222
tearDown()
Prototype function for cleaning up test environemnt. It will be called after each test has executed...
Definition: QUnit.qm.dox.h:589
Class representing Exception of a particular type and substring for detail.
Definition: QUnit.qm.dox.h:307
An abstract class representing test result interface.
Definition: QUnit.qm.dox.h:156
Class representing Exception of a particular type.
Definition: QUnit.qm.dox.h:234
number number(softnumber n)
binary binary()
Class representing boolean True.
Definition: QUnit.qm.dox.h:173
const False
Class containing the configuration for a test case.
Definition: QUnit.qm.dox.h:317
string m_exceptionType
corresponds to the "err" key of ExceptionInfo (the first value of a throw statement) ...
Definition: QUnit.qm.dox.h:239
setUp()
A prototype function.
Definition: QUnit.qm.dox.h:1160
list list(...)
the main namespace for all public definitions in the QUnit module
Definition: QUnit.qm.dox.h:153
hash m_options
the result of parsing command-line options with Qore::GetOpt::parse2()
Definition: QUnit.qm.dox.h:427
Base class for collecting test results and reporting.
Definition: QUnit.qm.dox.h:391
hash m_printMethods
A map of print methods, categorised into three types: header, summary, testreport.
Definition: QUnit.qm.dox.h:416
globalTearDown()
global tear down; will be called once after all tests are run
Definition: QUnit.qm.dox.h:583
string m_name
test case name
Definition: QUnit.qm.dox.h:430
string m_version
test case version
Definition: QUnit.qm.dox.h:432
Class representing Exception of a particular type and matching regexp for detail. ...
Definition: QUnit.qm.dox.h:289
const NOTHING
string type(auto arg)
globalSetUp()
global setup; will be called once before tests are run
Definition: QUnit.qm.dox.h:580
setUp()
Prototype function for setting up test environment. It will be called for each test individually...
Definition: QUnit.qm.dox.h:586
code m_code
the body of the test case
Definition: QUnit.qm.dox.h:325
Class representing test function failure, both unspecific and with detail.
Definition: QUnit.qm.dox.h:186
hash hash(object obj)
*list< auto > m_args
arguments to the above callable object
Definition: QUnit.qm.dox.h:328
Base class representing a simple test, implements an implicit main() function and all utility functio...
Definition: QUnit.qm.dox.h:529