QUnit.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file QUnit.qm Qore user module for automatic testing
namespace QUnit {}
class QUnit::AbstractTestResult {
public:
public :
string m_type;
*string m_subType;
auto m_value;
public:
constructor(string type);
constructor(string type, string subType);
// test
abstract bool equals(AbstractTestResult r); abstract string toString();};
class QUnit::TestResultSuccess : public QUnit::AbstractTestResult {
public:
constructor() ;
bool equals(QUnit::AbstractTestResult r);
string toString();
};
class QUnit::TestResultFailure : public QUnit::AbstractTestResult {
public:
private :
*string m_detail;
public:
constructor() ;
constructor(string s) ;
bool equals(QUnit::AbstractTestResult r);
string toString();
};
class QUnit::TestResultValue : public QUnit::AbstractTestResult {
public:
constructor(auto value) ;
bool equals(QUnit::AbstractTestResult r);
string toString();
};
class QUnit::TestResultPartialHashMatch : public QUnit::AbstractTestResult {
public:
constructor(hash value) ;
bool equals(QUnit::AbstractTestResult r);
string toString();
};
class QUnit::TestResultExceptionType : public QUnit::AbstractTestResult {
public:
public :
string m_exceptionType;
public:
constructor(string exceptionType) ;
private:
constructor(string exceptionType, string subType) ;
public:
bool equals(QUnit::AbstractTestResult r);
string toString();
};
class QUnit::TestResultExceptionDetail : public QUnit::TestResultExceptionType {
public:
private :
string m_exceptionDetail;
public:
constructor(string exceptionType, string exceptionDetail) ;
bool equals(QUnit::AbstractTestResult r);
string toString();
string getDetail();
};
class QUnit::TestResultExceptionRegexp : public QUnit::TestResultExceptionType {
public:
private :
string m_exceptionRegexp;
public:
constructor(string exceptionType, string exceptionRegexp) ;
bool equals(QUnit::AbstractTestResult r);
string toString();
};
class QUnit::TestResultExceptionSubstring : public QUnit::TestResultExceptionRegexp {
public:
constructor(string exceptionType, string exceptionSubstring) ;
string toString();
};
class QUnit::TestCase {
public:
private :
string m_name;
code m_code;
*list<auto> m_args;
int num_asserts = 0;
int num_asserts_ok = 0;
int num_asserts_skip = 0;
public:
constructor(string name, code code, *softlist<auto> args);
run(QUnit::Test test);
static list<string> getStackList(list stack, bool ok = False);
static string getPos(hash ex);
checkException(QUnit::Test test, hash e);
string getName();
incAssertions();
incAssertionsOk();
incAssertionsSkip();
int getAssertionCount();
int getAssertionOkCount();
int getAssertionSkipCount();
setupThread();
restoreThread();
rename(string n_name);
};
class QUnit::TestReporter {
public:
private :
const PLAINQUIET = 0;
const PLAIN = 1;
const JUNIT = 2;
const OUT_TYPES = (
"plainquiet" : PLAINQUIET,
"plain" : PLAIN,
"junit" : JUNIT,
);
const RESULT_TYPE_DESCRIPTION = (
TEST_SUCCESS : ("desc": "Success", "junittag" : NOTHING), // Success does not have a junit child tag
TEST_FAILURE : ("desc": "FAILURE", "junittag" : "failure"),
TEST_ERROR : ("desc": "ERROR", "junittag" : "error"),
TEST_SKIPPED : ("desc": "Skipped", "junittag" : "skipped"),
);
const OffsetColumn = 20;
hash m_printMethods;
list m_results = ();
int m_output;
*string m_comment;
hash m_options;
string m_name;
string m_version;
int num_asserts = 0;
int num_asserts_ok = 0;
int num_asserts_skip = 0;
public:
public :
const Opts = (
"help" : "h,help",
"verbose" : "v,verbose:i+",
"quiet" : "q,quiet",
"format" : "format=s",
);
const TEST_SUCCESS = 0;
const TEST_FAILURE = 1;
const TEST_ERROR = 2;
const TEST_SKIPPED = 3;
public:
private:
printOption(string left, string right, int offset = OffsetColumn);
public:
private:
usageIntern(int offset = OffsetColumn);
public:
private:
usage();
public:
private:
processOptions(reference<list<string>> p_argv);
public:
constructor(string name, string version, *reference<list<string>> p_argv, hash opts = Opts);
private:
callPrinterFunction(string type, *softlist<auto> args);
public:
private:
printHeader() { callPrinterFunction("header"); } printSummary() { callPrinterFunction("summary"); } printTestReport(hash testcase) { callPrinterFunction("testreport", testcase); }
printPlaintextHeader();
printPlaintextSummary();
printPlaintextOneTest(hash testcase);
printJunitSummary();
int errors();
int skipped();
int testCount();
addTestResult(TestCase tc, int success, *string error, *string pos, *string detail);
};
class QUnit::Test : public QUnit::TestReporter {
public:
private :
list<TestCase> testCases();
static QUnit::TestResultSuccess RESULT_SUCCESS = new QUnit::TestResultSuccess();
static QUnit::TestResultFailure RESULT_FAILURE = new QUnit::TestResultFailure();
public:
private:internal {
const QUC_EQ = "eq";
const QUC_NEQ = "neq";
const QUC_GT = "gt";
const QUC_GE = "ge";
const QUC_LT = "lt";
const QUC_LE = "le";
const QUC_RE = "re";
const QUC_NRE = "nre";
const QUC_Map = (
QUC_EQ: NOTHING,
QUC_NEQ: "Not Equal",
QUC_GT: "Greater Than",
QUC_GE: "Greater Than Or Equal To",
QUC_LT: "Less Than",
QUC_LE: "Less Than Or Equal To",
QUC_RE: "Regular Expression Match",
QUC_NRE: "Negative Regular Expression Match",
);
const DEFAULT_EPSILON = 0.0000000001;
}
constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
globalSetUp() {}
globalTearDown() {}
setUp() {}
tearDown() {}
*string getEnv(string key, *string def);
addTestCase(string name, code call, *softlist<auto> args);
addTestCase(QUnit::TestCase tc);
string escapeSpecialChars(string str);
bool diffInSpecialCharsOnly(string a, string b);
string printUnexpectedData(auto exp, auto act, *bool neg, *bool soft_comparisons, *string comparitor);
string shorten(auto value);
compare(auto v1, auto v2, reference<list<string>> out, string path, *bool soft_comparisons);
compareHashes(hash h1, hash h2, reference<list<string>> out, string path = "", *bool soft_comparisons);
compareLists(list<auto> l1, list<auto> l2, reference<list<string>> out, string path = "", *bool soft_comparisons);
//######## Assertions & test control functions
auto testAssertionValue(*string name, auto actual, auto expected);
auto testAssertionValue(*string name, number actual, number expected, number epsilon = DEFAULT_EPSILON);
auto testAssertionValue(*string name, float actual, float expected, float epsilon = DEFAULT_EPSILON);
assertRegex(string regex_pattern, string actual, *string name);
assertNRegex(string regex_pattern, string actual, *string name);
assertNothing(auto actual, *string name);
assertEqSoft(auto expected, auto actual, *string name);
assertNeqSoft(auto expected, auto actual, *string name);
assertEq(auto expected, auto actual, *string name);
assertNeq(auto expected, auto actual, *string name);
assertFloatEq(float expected, float actual, float epsilon = DEFAULT_EPSILON, *string name);
assertNumberEq(number expected, number actual, number epsilon = DEFAULT_EPSILON, *string name);
assertGtSoft(auto expected, auto actual, *string name);
assertGt(auto expected, auto actual, *string name);
assertGeSoft(auto expected, auto actual, *string name);
assertGe(auto expected, auto actual, *string name);
assertLtSoft(auto expected, auto actual, *string name);
assertLt(auto expected, auto actual, *string name);
assertLeSoft(auto expected, auto actual, *string name);
assertLe(auto expected, auto actual, *string name);
assertionOk(*string name);
assertTrue(auto actual, *string name);
assertFalse(auto actual, *string name);
assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist<auto> args, *string name);
assertThrows(string expectedErr, code theCode, *softlist<auto> args, *string name);
assertSkip (*string name);
TestCase getTestCase(string meth);
fail(*string msg);
testNullAssertion(string name, code condition, *softlist<auto> args);
auto testAssertion(string name, code condition, *softlist<auto> args, int expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, float expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, number expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, bool expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, string expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, date expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, binary expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, hash expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, list expectedResultValue);
auto testAssertion(string name, code condition, *softlist<auto> args, QUnit::AbstractTestResult expectedResult = new QUnit::TestResultSuccess());
auto testAssertionIntern(TestCase tc, string name, QUnit::AbstractTestResult actualResult, QUnit::AbstractTestResult expectedResult, auto ret, *string pos);
testSkip(string reason);
//######## Test conditions passable to test assertions
bool equals(auto a, auto b);
bool notEquals(auto a, auto b);
bool regexpMatches(string s, string regexp);
bool equalsIterated(AbstractIterator a, AbstractIterator b);
//######## Main function and test running helpers
int main();
static string getAssertionName(*string name);
};
class QUnit::DependencyInjectedTest : public QUnit::Test {
public:
private :
*string m_testedFile;
Program m_child;
*hash m_modules;
static bool instantiated = False;
public:
constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
setScriptPath(*string testedFile);
setUp() { }
tearDown() { }
Program createInjectedProgram();
abstract performInjections(Program p);
abstract performModuleInjections();
injectIntoModule(string module);
destructor();
int main();
};
class QUnit::DependencyInjectedTestRunner : public QUnit::Test {
public:
setScriptPath(*string testedFile) {} injectIntoModule(string module) {}
constructor(string name, string version, *reference<list<string>> p_argv, *hash opts) ;
};
rename
nothing rename(string old_path, string new_path)
date
date date(date dt)
QUnit::TestResultExceptionDetail
Class representing Exception of a particular type with a particular detail message.
Definition: QUnit.qm.dox.h:261
QUnit::TestResultValue
Class representing any non-boolean value.
Definition: QUnit.qm.dox.h:206
exp
number exp(number n)
QUnit::TestCase::m_name
string m_name
the name of the test case
Definition: QUnit.qm.dox.h:319
QUnit::DependencyInjectedTest
A class representing a test with injected dependencies.
Definition: QUnit.qm.dox.h:1137
QUnit::TestResultPartialHashMatch
Class representing a partial match of a hash value. Common keys have to be identical.
Definition: QUnit.qm.dox.h:219
QUnit::Test::tearDown
tearDown()
Prototype function for cleaning up test environemnt. It will be called after each test has executed...
Definition: QUnit.qm.dox.h:586
QUnit::TestResultExceptionSubstring
Class representing Exception of a particular type and substring for detail.
Definition: QUnit.qm.dox.h:304
QUnit::AbstractTestResult
An abstract class representing test result interface.
Definition: QUnit.qm.dox.h:153
QUnit::TestResultExceptionType
Class representing Exception of a particular type.
Definition: QUnit.qm.dox.h:231
number
number number(softnumber n)
binary
binary binary()
QUnit::TestResultSuccess
Class representing boolean True.
Definition: QUnit.qm.dox.h:170
False
const False
QUnit::TestCase
Class containing the configuration for a test case.
Definition: QUnit.qm.dox.h:314
QUnit::TestResultExceptionType::m_exceptionType
string m_exceptionType
corresponds to the "err" key of ExceptionInfo (the first value of a throw statement) ...
Definition: QUnit.qm.dox.h:236
QUnit::DependencyInjectedTest::setUp
setUp()
A prototype function.
Definition: QUnit.qm.dox.h:1157
list
list list(...)
QUnit
the main namespace for all public definitions in the QUnit module
Definition: QUnit.qm.dox.h:150
QUnit::TestReporter::m_options
hash m_options
the result of parsing command-line options with Qore::GetOpt::parse2()
Definition: QUnit.qm.dox.h:424
QUnit::TestReporter
Base class for collecting test results and reporting.
Definition: QUnit.qm.dox.h:388
QUnit::TestReporter::m_printMethods
hash m_printMethods
A map of print methods, categorised into three types: header, summary, testreport.
Definition: QUnit.qm.dox.h:413
QUnit::Test::globalTearDown
globalTearDown()
global tear down; will be called once after all tests are run
Definition: QUnit.qm.dox.h:580
QUnit::TestReporter::m_name
string m_name
test case name
Definition: QUnit.qm.dox.h:427
QUnit::TestReporter::m_version
string m_version
test case version
Definition: QUnit.qm.dox.h:429
QUnit::TestResultExceptionRegexp
Class representing Exception of a particular type and matching regexp for detail. ...
Definition: QUnit.qm.dox.h:286
NOTHING
const NOTHING
type
string type(auto arg)
QUnit::Test::globalSetUp
globalSetUp()
global setup; will be called once before tests are run
Definition: QUnit.qm.dox.h:577
QUnit::Test::setUp
setUp()
Prototype function for setting up test environment. It will be called for each test individually...
Definition: QUnit.qm.dox.h:583
QUnit::TestCase::m_code
code m_code
the body of the test case
Definition: QUnit.qm.dox.h:322
QUnit::TestResultFailure
Class representing test function failure, both unspecific and with detail.
Definition: QUnit.qm.dox.h:183
hash
hash hash(object obj)
QUnit::TestCase::m_args
*list< auto > m_args
arguments to the above callable object
Definition: QUnit.qm.dox.h:325
QUnit::Test
Base class representing a simple test, implements an implicit main() function and all utility functio...
Definition: QUnit.qm.dox.h:526