Qore QUnit Module Reference  0.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 
128 namespace QUnit {}
130 
133 
134 public:
135  public :
136  string m_type;
137  *string m_subType;
138  auto m_value;
139 
140 public:
141  constructor(string type);
142 
143  constructor(string type, string subType);
144 
145  // test
146  abstract bool equals(AbstractTestResult r); abstract string toString();};
147 
150 
151 public:
152  constructor() ;
153 
154 
156  bool equals(QUnit::AbstractTestResult r);
157 
158  string toString();
159 };
160 
163 
164 public:
165  private :
166  *string m_detail;
167 
168 public:
169 
171  constructor() ;
172 
173 
175  constructor(string s) ;
176 
177 
179  bool equals(QUnit::AbstractTestResult r);
180 
181  string toString();
182 };
183 
186 
187 public:
188  constructor(auto value) ;
189 
190 
192  bool equals(QUnit::AbstractTestResult r);
193 
194  string toString();
195 };
196 
199 
200 public:
201  constructor(hash value) ;
202 
203 
204  bool equals(QUnit::AbstractTestResult r);
205 
206  string toString();
207 };
208 
211 
212 public:
213  public :
216 
217 public:
218 
220 
222  constructor(string exceptionType) ;
223 
224 
226 
227 private:
228  constructor(string exceptionType, string subType) ;
229 public:
230 
231 
233  bool equals(QUnit::AbstractTestResult r);
234 
236  string toString();
237 };
238 
241 
242 public:
243  private :
244  string m_exceptionDetail;
245 
246 public:
247 
249 
252  constructor(string exceptionType, string exceptionDetail) ;
253 
254 
256  bool equals(QUnit::AbstractTestResult r);
257 
258  string toString();
259 
260  string getDetail();
261 
262 };
263 
266 
267 public:
268  private :
269  string m_exceptionRegexp;
270 
271 public:
272 
273  constructor(string exceptionType, string exceptionRegexp) ;
274 
275 
277  bool equals(QUnit::AbstractTestResult r);
278 
279  string toString();
280 };
281 
284 
285 public:
286  constructor(string exceptionType, string exceptionSubstring) ;
287 
288 
289  string toString();
290 };
291 
294 
295 public:
296  private :
298  string m_name;
299 
301  code m_code;
302 
304  *list<auto> m_args;
305 
307  int num_asserts = 0;
308 
310  int num_asserts_ok = 0;
311 
313  int num_asserts_skip = 0;
314 
315 public:
316 
318  constructor(string name, code code, *softlist<auto> args);
319 
320 
322  run(QUnit::Test test);
323 
324 
325  static *string getStackPos(list stack);
326 
327  static string getPos(hash ex);
328 
330  checkException(QUnit::Test test, hash e);
331 
332 
334  string getName();
335 
336 
337  incAssertions();
338 
339 
340  incAssertionsOk();
341 
342 
343  incAssertionsSkip();
344 
345 
346  int getAssertionCount();
347 
348 
349  int getAssertionOkCount();
350 
351 
352  int getAssertionSkipCount();
353 
354 
355  setupThread();
356 
357 
358  restoreThread();
359 
360 
362  rename(string n_name);
363 
364 };
365 
368 
369 public:
370  private :
371  const PLAINQUIET = 0;
372  const PLAIN = 1;
373  const JUNIT = 2;
374 
375  const OUT_TYPES = (
376  "plainquiet" : PLAINQUIET,
377  "plain" : PLAIN,
378  "junit" : JUNIT,
379  );
380 
381  const RESULT_TYPE_DESCRIPTION = (
382  TEST_SUCCESS : ("desc": "Success", "junittag" : NOTHING), // Success does not have a junit child tag
383  TEST_FAILURE : ("desc": "FAILURE", "junittag" : "failure"),
384  TEST_ERROR : ("desc": "ERROR", "junittag" : "error"),
385  TEST_SKIPPED : ("desc": "Skipped", "junittag" : "skipped"),
386  );
387 
389  const OffsetColumn = 20;
390 
393 
394  list m_results = ();
395  int m_output;
396  *string m_comment;
397 
399 
404 
406  string m_name;
408  string m_version;
409 
411  int num_asserts = 0;
412 
414  int num_asserts_ok = 0;
415 
417  int num_asserts_skip = 0;
418 
419 public:
420 
421  public :
423  const Opts = (
424  "help" : "h,help",
425  "verbose" : "v,verbose:i+",
426  "quiet" : "q,quiet",
427  "format" : "format=s",
428  );
429 
430  const TEST_SUCCESS = 0;
431  const TEST_FAILURE = 1;
432  const TEST_ERROR = 2;
433  const TEST_SKIPPED = 3;
434 
435 public:
436 
437 
438 private:
439  printOption(string left, string right, int offset = OffsetColumn);
440 public:
441 
442 
443 
444 private:
445  usageIntern(int offset = OffsetColumn);
446 public:
447 
448 
449 
450 private:
451  usage();
452 public:
453 
454 
455 
456 private:
457  processOptions(reference<list<string>> p_argv);
458 public:
459 
460 
462 
467  constructor(string name, string version, *reference<list<string>> p_argv, hash opts = Opts);
468 
469 
470 
471 private:
472  callPrinterFunction(string type, *softlist<auto> args);
473 public:
474 
475 
476 
477 private:
478  printHeader() { callPrinterFunction("header"); } printSummary() { callPrinterFunction("summary"); } printTestReport(hash testcase) { callPrinterFunction("testreport", testcase); }
479  printPlaintextHeader();
480 
481  printPlaintextSummary();
482 
483  printPlaintextOneTest(hash testcase);
484 
485  printJunitSummary();
486 
488  int errors();
489 
490 
492  int skipped();
493 
494 
496  int testCount();
497 
498 
500  addTestResult(TestCase tc, int success, *string error, *string pos, *string detail);
501 
502 };
503 
506 
507 public:
508  private :
510  list<TestCase> testCases();
511 
512  static QUnit::TestResultSuccess RESULT_SUCCESS = new QUnit::TestResultSuccess();
513  static QUnit::TestResultFailure RESULT_FAILURE = new QUnit::TestResultFailure();
514 
515 public:
516 
518  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
519 
520 
523 
526 
528  setUp() {}
529 
531  tearDown() {}
532 
534  *string getEnv(string key, *string def);
535 
536 
538 
547  addTestCase(string name, code call, *softlist<auto> args);
548 
549 
551 
558  addTestCase(QUnit::TestCase tc);
559 
560 
561  string escapeSpecialChars(string str);
562 
563  bool diffInSpecialCharsOnly(string a, string b);
564 
566  string printUnexpectedData(auto exp, auto act, *bool neg, *bool soft_comparisons);
567 
568  string shorten(auto value);
569 
570  compare(auto v1, auto v2, reference<list<string>> out, string path, *bool soft_comparisons);
571 
572  compareHashes(hash h1, hash h2, reference<list<string>> out, string path = "", *bool soft_comparisons);
573 
574  compareLists(list<auto> l1, list<auto> l2, reference<list<string>> out, string path = "", *bool soft_comparisons);
575 
576 //######## Assertions & test control functions
577 
579 
592  auto testAssertionValue(*string name, auto actual, auto expected);
593 
595 
604  assertEqSoft(auto expected, auto actual, *string name);
605 
607 
616  assertEq(auto expected, auto actual, *string name);
617 
619 
629  assertFloatEq(float expected, float actual, float epsilon = 0.0000000001, *string name);
630 
632 
642  assertNumberEq(number expected, number actual, number epsilon = 0.0000000001, *string name);
643 
645 
653  assertTrue(auto actual, *string name);
654 
656 
664  assertFalse(auto actual, *string name);
665 
667 
678  assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist<auto> args, *string name);
679 
681 
691  assertThrows(string expectedErr, code theCode, *softlist<auto> args, *string name);
692 
694 
702  assertSkip (*string name);
703 
705  TestCase getTestCase(string meth);
706 
707 
709 
716  fail(*string msg);
717 
719 
726  testNullAssertion(string name, code condition, *softlist<auto> args);
727 
729 
737  auto testAssertion(string name, code condition, *softlist<auto> args, int expectedResultValue);
738 
740 
748  auto testAssertion(string name, code condition, *softlist<auto> args, float expectedResultValue);
749 
751 
759  auto testAssertion(string name, code condition, *softlist<auto> args, number expectedResultValue);
760 
762 
770  auto testAssertion(string name, code condition, *softlist<auto> args, bool expectedResultValue);
771 
773 
781  auto testAssertion(string name, code condition, *softlist<auto> args, string expectedResultValue);
782 
784 
792  auto testAssertion(string name, code condition, *softlist<auto> args, date expectedResultValue);
793 
795 
803  auto testAssertion(string name, code condition, *softlist<auto> args, binary expectedResultValue);
804 
806 
814  auto testAssertion(string name, code condition, *softlist<auto> args, hash expectedResultValue);
815 
817 
825  auto testAssertion(string name, code condition, *softlist<auto> args, list expectedResultValue);
826 
828 
836  auto testAssertion(string name, code condition, *softlist<auto> args, QUnit::AbstractTestResult expectedResult = new QUnit::TestResultSuccess());
837 
838  auto testAssertionIntern(TestCase tc, string name, QUnit::AbstractTestResult actualResult, QUnit::AbstractTestResult expectedResult, auto ret, *string pos);
839 
841 
844  testSkip(string reason);
845 
846 //######## Test conditions passable to test assertions
847 
849 
855  bool equals(auto a, auto b);
856 
857 
859 
865  bool notEquals(auto a, auto b);
866 
867 
869 
875  bool regexpMatches(string s, string regexp);
876 
877 
879 
885  bool equalsIterated(AbstractIterator a, AbstractIterator b);
886 
887 
888 //######## Main function and test running helpers
889 
891  int main();
892 
893 
895  static string getAssertionName(*string name);
896 };
897 
900 
901 public:
902  private :
903  *string m_testedFile;
904  Program m_child;
905  *hash m_modules;
906 
907  static bool instantiated = False;
908 
909 public:
910 
911  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
912 
913 
915  setScriptPath(*string testedFile);
916 
917 
919  setUp() { }
920  tearDown() { }
921 
922  Program createInjectedProgram();
923 
924  abstract performInjections(Program p);
925  abstract performModuleInjections();
926 
927  injectIntoModule(string module);
928 
929  destructor();
930 
931 
932  int main();
933 
934 };
935 
936 class QUnit::DependencyInjectedTestRunner : public QUnit::Test {
937 
938 public:
939  setScriptPath(*string testedFile) {} injectIntoModule(string module) {}
940  constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
941 
942 };
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:240
Class representing any non-boolean value.
Definition: QUnit.qm.dox.h:185
number exp(number n)
string m_name
the name of the test case
Definition: QUnit.qm.dox.h:298
A class representing a test with injected dependencies.
Definition: QUnit.qm.dox.h:899
Class representing a partial match of a hash value. Common keys have to be identical.
Definition: QUnit.qm.dox.h:198
tearDown()
Prototype function for cleaning up test environemnt. It will be called after each test has executed...
Definition: QUnit.qm.dox.h:531
Class representing Exception of a particular type and substring for detail.
Definition: QUnit.qm.dox.h:283
An abstract class representing test result interface.
Definition: QUnit.qm.dox.h:132
Class representing Exception of a particular type.
Definition: QUnit.qm.dox.h:210
number number(softnumber n)
binary binary()
Class representing boolean True.
Definition: QUnit.qm.dox.h:149
const False
Class containing the configuration for a test case.
Definition: QUnit.qm.dox.h:293
string m_exceptionType
corresponds to the "err" key of ExceptionInfo (the first value of a throw statement) ...
Definition: QUnit.qm.dox.h:215
setUp()
A prototype function.
Definition: QUnit.qm.dox.h:919
list list(...)
the main namespace for all public definitions in the QUnit module
Definition: QUnit.qm.dox.h:129
hash m_options
the result of parsing command-line options with Qore::GetOpt::parse2()
Definition: QUnit.qm.dox.h:403
Base class for collecting test results and reporting.
Definition: QUnit.qm.dox.h:367
hash m_printMethods
A map of print methods, categorised into three types: header, summary, testreport.
Definition: QUnit.qm.dox.h:392
globalTearDown()
global tear down; will be called once after all tests are run
Definition: QUnit.qm.dox.h:525
string m_name
test case name
Definition: QUnit.qm.dox.h:406
string m_version
test case version
Definition: QUnit.qm.dox.h:408
Class representing Exception of a particular type and matching regexp for detail. ...
Definition: QUnit.qm.dox.h:265
const NOTHING
string type(auto arg)
globalSetUp()
global setup; will be called once before tests are run
Definition: QUnit.qm.dox.h:522
setUp()
Prototype function for setting up test environment. It will be called for each test individually...
Definition: QUnit.qm.dox.h:528
code m_code
the body of the test case
Definition: QUnit.qm.dox.h:301
Class representing test function failure, both unspecific and with detail.
Definition: QUnit.qm.dox.h:162
hash hash(object obj)
*list< auto > m_args
arguments to the above callable object
Definition: QUnit.qm.dox.h:304
Base class representing a simple test, implements an implicit main() function and all utility functio...
Definition: QUnit.qm.dox.h:505