All Classes Namespaces Functions Variables Groups Pages
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) ;
};
QUnit::Test::assertFalse
assertFalse(auto actual, *string name)
Tests a boolean value.
QUnit::Test::assertNeqSoft
assertNeqSoft(auto expected, auto actual, *string name)
Tests a value for inequality to an expected value with soft comparisons (types may differ) ...
date
date date(date dt)
QUnit::Test::assertionOk
assertionOk(*string name)
process an ok assertion
QUnit::Test::testAssertionValue
auto testAssertionValue(*string name, auto actual, auto expected)
Tests a value for equality to an expected value.
QUnit::TestResultExceptionDetail
Class representing Exception of a particular type with a particular detail message.
Definition: QUnit.qm.dox.h:264
QUnit::TestResultValue
Class representing any non-boolean value.
Definition: QUnit.qm.dox.h:209
exp
number exp(number n)
QUnit::TestResultExceptionDetail::toString
string toString()
returns a string describing the exception type
QUnit::Test::QUC_GT
const QUC_GT
greater than comparitor
Definition: QUnit.qm.dox.h:547
QUnit::TestCase::m_name
string m_name
the name of the test case
Definition: QUnit.qm.dox.h:322
QUnit::TestReporter::addTestResult
addTestResult(TestCase tc, int success, *string error, *string pos, *string detail)
adds a test result
QUnit::DependencyInjectedTest
A class representing a test with injected dependencies.
Definition: QUnit.qm.dox.h:1140
QUnit::TestResultPartialHashMatch
Class representing a partial match of a hash value. Common keys have to be identical.
Definition: QUnit.qm.dox.h:222
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:589
QUnit::TestReporter::OffsetColumn
const OffsetColumn
the default column offset for printing options used in printOption() and usageIntern() ...
Definition: QUnit.qm.dox.h:413
QUnit::TestReporter::constructor
constructor(string name, string version, *reference< list< string >> p_argv, hash opts=Opts)
creates the object from the arguments
QUnit::TestResultExceptionSubstring::toString
string toString()
returns a string describing the exception type
QUnit::TestResultSuccess::equals
bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::Test::getTestCase
TestCase getTestCase(string meth)
returns the current test case
QUnit::TestResultExceptionSubstring
Class representing Exception of a particular type and substring for detail.
Definition: QUnit.qm.dox.h:307
QUnit::Test::assertSkip
assertSkip(*string name)
Skips assertion on purpose.
QUnit::AbstractTestResult
An abstract class representing test result interface.
Definition: QUnit.qm.dox.h:156
QUnit::Test::fail
fail(*string msg)
Fails the test unconditionally.
QUnit::Test::assertLe
assertLe(auto expected, auto actual, *string name)
Tests that a value is less than or equal to an expected value with hard comparisons (types may not di...
QUnit::TestResultExceptionType
Class representing Exception of a particular type.
Definition: QUnit.qm.dox.h:234
QUnit::TestReporter::num_asserts_skip
int num_asserts_skip
total number of skipped assertions in script
Definition: QUnit.qm.dox.h:441
QUnit::Test::testAssertion
auto testAssertion(string name, code condition, *softlist< auto > args, int expectedResultValue)
Tests for a single assertion for a call returning an integer value and returns the value generated...
QUnit::Test::assertEq
assertEq(auto expected, auto actual, *string name)
Tests a value for equality to an expected value with hard comparisons (types and values must be ident...
number
number number(softnumber n)
QUnit::TestCase::num_asserts
int num_asserts
number of assertions in current test case
Definition: QUnit.qm.dox.h:331
QUnit::TestResultFailure::constructor
constructor()
Instantiate an unspecific failure, no detail.
QUnit::DependencyInjectedTest::setScriptPath
setScriptPath(*string testedFile)
A helper function. It must be called once for a new instance with get_script_path() as argument...
binary
binary binary()
QUnit::Test::assertLt
assertLt(auto expected, auto actual, *string name)
Tests that a value is less than an expected value with hard comparisons (types may not differ) ...
QUnit::TestResultSuccess
Class representing boolean True.
Definition: QUnit.qm.dox.h:173
QUnit::Test::assertEqSoft
assertEqSoft(auto expected, auto actual, *string name)
Tests a value for equality to an expected value with soft comparisons (types may differ) ...
QUnit::TestCase::constructor
constructor(string name, code code, *softlist< auto > args)
creates the TestCase object from the given arguments
QUnit::TestReporter::num_asserts
int num_asserts
total number of assertions in script
Definition: QUnit.qm.dox.h:435
False
const False
QUnit::TestCase
Class containing the configuration for a test case.
Definition: QUnit.qm.dox.h:317
QUnit::TestResultExceptionType::m_exceptionType
string m_exceptionType
corresponds to the &quot;err&quot; key of ExceptionInfo (the first value of a throw statement) ...
Definition: QUnit.qm.dox.h:239
QUnit::Test::QUC_RE
const QUC_RE
regex comparitor
Definition: QUnit.qm.dox.h:555
QUnit::Test::assertGe
assertGe(auto expected, auto actual, *string name)
Tests that a value is greater than or equal to an expected value with hard comparisons (types may not...
QUnit::Test::assertNothing
assertNothing(auto actual, *string name)
Tests for no vlaue.
QUnit::DependencyInjectedTest::setUp
setUp()
A prototype function.
Definition: QUnit.qm.dox.h:1160
QUnit::Test::assertNeq
assertNeq(auto expected, auto actual, *string name)
Tests a value for inequality to an expected value with hard comparisons (types and values must be ide...
QUnit::Test::assertLtSoft
assertLtSoft(auto expected, auto actual, *string name)
Tests that a value is less than an expected value with soft comparisons (types may differ) ...
list
list list(...)
QUnit::Test::constructor
constructor(string name, string version, *reference< list< string >> p_argv, *hash opts)
creates the object and sets the name of the test
QUnit::Test::assertLeSoft
assertLeSoft(auto expected, auto actual, *string name)
Tests that a value is less than or equal to than an expected value with soft comparisons (types may d...
QUnit::TestReporter::m_options
hash m_options
the result of parsing command-line options with Qore::GetOpt::parse2()
Definition: QUnit.qm.dox.h:427
QUnit::Test::printUnexpectedData
string printUnexpectedData(auto exp, auto act, *bool neg, *bool soft_comparisons, *string comparitor)
Helper function for printing out human-readable comparison of two values.
QUnit::TestReporter
Base class for collecting test results and reporting.
Definition: QUnit.qm.dox.h:391
QUnit::TestCase::num_asserts_ok
int num_asserts_ok
number of successful assertions in current test case
Definition: QUnit.qm.dox.h:334
QUnit::TestResultExceptionDetail::constructor
constructor(string exceptionType, string exceptionDetail)
creates the object from the exception arguments
QUnit::TestResultFailure::equals
bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::Test::assertGt
assertGt(auto expected, auto actual, *string name)
Tests that a value is greater than an expected value with hard comparisons (types may not differ) ...
QUnit::TestResultExceptionType::constructor
constructor(string exceptionType)
creates the object from the exception arguments
QUnit::Test::addTestCase
addTestCase(string name, code call, *softlist< auto > args)
adds a test case to run
QUnit::Test::testSkip
testSkip(string reason)
Skips a given test, eg. because it may be missing some dependencies.
QUnit::TestReporter::m_printMethods
hash m_printMethods
A map of print methods, categorised into three types: header, summary, testreport.
Definition: QUnit.qm.dox.h:416
QUnit::Test::globalTearDown
globalTearDown()
global tear down; will be called once after all tests are run
Definition: QUnit.qm.dox.h:583
QUnit::Test::assertRegex
assertRegex(string regex_pattern, string actual, *string name)
Tests that a test value passes a regular expression match.
QUnit::Test::QUC_GE
const QUC_GE
greater than or equals comparitor
Definition: QUnit.qm.dox.h:549
QUnit::TestResultExceptionDetail::equals
bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::TestReporter::m_name
string m_name
test case name
Definition: QUnit.qm.dox.h:430
QUnit::Test::main
int main()
Run the whole suite, report results.
QUnit::Test::equalsIterated
bool equalsIterated(AbstractIterator a, AbstractIterator b)
Compare two iterables, item by item, for equality of each index.
QUnit::Test::assertNumberEq
assertNumberEq(number expected, number actual, number epsilon=DEFAULT_EPSILON, *string name)
Tests a number value for equality to an expected value with an allowed error.
QUnit::Test::QUC_LT
const QUC_LT
greater than comparitor
Definition: QUnit.qm.dox.h:551
QUnit::TestReporter::errors
int errors()
returns the number of errors encountered during test execution
QUnit::TestCase::getName
string getName()
returns the test case name
QUnit::TestReporter::m_version
string m_version
test case version
Definition: QUnit.qm.dox.h:432
QUnit::Test::DEFAULT_EPSILON
const DEFAULT_EPSILON
default epsilon for number/float comparison
Definition: QUnit.qm.dox.h:572
QUnit::Test::assertFloatEq
assertFloatEq(float expected, float actual, float epsilon=DEFAULT_EPSILON, *string name)
Tests a float value for equality to an expected value with an allowed error.
QUnit::TestResultExceptionRegexp::toString
string toString()
returns a string describing the exception type
QUnit::Test::notEquals
bool notEquals(auto a, auto b)
Compare two values for inequality.
QUnit::TestResultExceptionRegexp
Class representing Exception of a particular type and matching regexp for detail. ...
Definition: QUnit.qm.dox.h:289
NOTHING
const NOTHING
QUnit::Test::assertThrows
assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist< auto > args, *string name)
Tests that a piece of code throws an exception with given description.
QUnit::TestReporter::num_asserts_ok
int num_asserts_ok
total number of successful assertions in script
Definition: QUnit.qm.dox.h:438
QUnit::Test::QUC_LE
const QUC_LE
greater than or equals comparitor
Definition: QUnit.qm.dox.h:553
QUnit::TestCase::checkException
checkException(QUnit::Test test, hash e)
handles exceptions raised while running the TestCase
QUnit::Test::QUC_Map
const QUC_Map
comparitor info
Definition: QUnit.qm.dox.h:560
type
string type(auto arg)
QUnit::Test::getAssertionName
static string getAssertionName(*string name)
returns the assertion name for display purposes
QUnit::Test::equals
bool equals(auto a, auto b)
Compare two values for equality.
QUnit::Test::globalSetUp
globalSetUp()
global setup; will be called once before tests are run
Definition: QUnit.qm.dox.h:580
QUnit::Test::assertGtSoft
assertGtSoft(auto expected, auto actual, *string name)
Tests that a value is greater than an expected value with soft comparisons (types may differ) ...
QUnit::TestCase::num_asserts_skip
int num_asserts_skip
number of skipped assertions in current test case
Definition: QUnit.qm.dox.h:337
QUnit::Test::regexpMatches
bool regexpMatches(string s, string regexp)
Compare a string for match against a regexp.
QUnit::TestResultExceptionRegexp::equals
bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::Test::setUp
setUp()
Prototype function for setting up test environment. It will be called for each test individually...
Definition: QUnit.qm.dox.h:586
QUnit::Test::assertTrue
assertTrue(auto actual, *string name)
Tests a boolean value.
QUnit::TestCase::run
run(QUnit::Test test)
runs the TestCase
QUnit::TestCase::m_code
code m_code
the body of the test case
Definition: QUnit.qm.dox.h:325
QUnit::TestResultExceptionType::equals
bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::TestResultFailure
Class representing test function failure, both unspecific and with detail.
Definition: QUnit.qm.dox.h:186
QUnit::Test::testNullAssertion
testNullAssertion(string name, code condition, *softlist< auto > args)
Tests for a single assertion for a call returning no value (for example, to ensure that the call does...
QUnit::TestReporter::skipped
int skipped()
returns the number of tests skipped
QUnit::Test::QUC_NEQ
const QUC_NEQ
inequality comparitor
Definition: QUnit.qm.dox.h:545
QUnit::Test::assertGeSoft
assertGeSoft(auto expected, auto actual, *string name)
Tests that a value is greater than or equal to than an expected value with soft comparisons (types ma...
QUnit::TestResultValue::equals
bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::Test::getEnv
*string getEnv(string key, *string def)
facade for the system environment variables
hash
hash hash(object obj)
QUnit::Test::QUC_NRE
const QUC_NRE
negative regex comparitor
Definition: QUnit.qm.dox.h:557
QUnit::TestReporter::Opts
const Opts
default options for Qore::GetOpt::constructor()
Definition: QUnit.qm.dox.h:447
QUnit::Test::testCases
list< TestCase > testCases()
list of test cases
QUnit::TestCase::rename
rename(string n_name)
renames the test case
QUnit::TestCase::m_args
*list< auto > m_args
arguments to the above callable object
Definition: QUnit.qm.dox.h:328
QUnit::TestReporter::testCount
int testCount()
returns the total number of test results
QUnit::TestResultExceptionType::toString
string toString()
returns a string describing the exception type
QUnit::Test::assertNRegex
assertNRegex(string regex_pattern, string actual, *string name)
Tests that a test value does not pass a regular expression match.
QUnit::Test
Base class representing a simple test, implements an implicit main() function and all utility functio...
Definition: QUnit.qm.dox.h:529