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;
any m_value;
public:
constructor(string type);
constructor(string type, string subType);
// test
abstract public bool equals(AbstractTestResult r);
abstract public string toString();
};
class QUnit::TestResultSuccess : public QUnit::AbstractTestResult {
public:
constructor() ;
public bool equals(QUnit::AbstractTestResult r);
public string toString();
};
class QUnit::TestResultFailure : public QUnit::AbstractTestResult {
public:
private :
*string m_detail;
public:
constructor() ;
constructor(string s) ;
public bool equals(QUnit::AbstractTestResult r);
public string toString();
};
class QUnit::TestResultValue : public QUnit::AbstractTestResult {
public:
constructor(any value) ;
public bool equals(QUnit::AbstractTestResult r);
public string toString();
};
class QUnit::TestResultPartialHashMatch : public QUnit::AbstractTestResult {
public:
constructor(hash value) ;
public bool equals(QUnit::AbstractTestResult r);
public 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);
public string toString();
};
class QUnit::TestResultExceptionDetail : public QUnit::TestResultExceptionType {
public:
private :
string m_exceptionDetail;
public:
constructor(string exceptionType, string exceptionDetail) ;
public bool equals(QUnit::AbstractTestResult r);
public string toString();
string getDetail();
};
class QUnit::TestResultExceptionRegexp : public QUnit::TestResultExceptionType {
public:
private :
string m_exceptionRegexp;
public:
constructor(string exceptionType, string exceptionRegexp) ;
public bool equals(QUnit::AbstractTestResult r);
public string toString();
};
class QUnit::TestResultExceptionSubstring : public QUnit::TestResultExceptionRegexp {
public:
constructor(string exceptionType, string exceptionSubstring) ;
public string toString();
};
class QUnit::TestCase {
public:
private :
string m_name;
code m_code;
*list m_args;
int num_asserts = 0;
int num_asserts_ok = 0;
int num_asserts_skip = 0;
public:
constructor(string name, code code, *softlist args);
run(QUnit::Test test);
static *string getStackPos(list stack);
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);
private usageIntern(int offset = OffsetColumn);
private usage();
private processOptions(reference p_argv);
constructor(string name, string version, *reference p_argv, hash opts = Opts);
private callPrinterFunction(string type, *softlist args);
private printHeader() { callPrinterFunction("header"); }
private printSummary() { callPrinterFunction("summary"); }
private printTestReport(hash testcase) { callPrinterFunction("testreport", testcase); }
private printPlaintextHeader();
private printPlaintextSummary();
private printPlaintextOneTest(hash testcase);
private 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 testCases = ();
static QUnit::TestResultSuccess RESULT_SUCCESS = new QUnit::TestResultSuccess();
static QUnit::TestResultFailure RESULT_FAILURE = new QUnit::TestResultFailure();
public:
constructor(string name, string version, *reference p_argv, *hash opts) ;
globalSetUp() {}
globalTearDown() {}
setUp() {}
tearDown() {}
*string getEnv(string key, *string def);
addTestCase(string name, code call, *softlist args);
addTestCase(QUnit::TestCase tc);
private string printUnexpectedData(any exp, any act, *bool neg, *bool soft_comparisons);
private string shorten(any value);
private compare(any v1, any v2, reference out, string path, *bool soft_comparisons);
private compareHashes(hash h1, hash h2, reference out, string path = "", *bool soft_comparisons);
private compareLists(list l1, list l2, reference out, string path = "", *bool soft_comparisons);
//######## Assertions & test control functions
public any testAssertionValue(*string name, any actual, any expected);
public assertEqSoft(any expected, any actual, *string name);
public assertEq(any expected, any actual, *string name);
public assertFloatEq(float expected, float actual, float epsilon = 0.0000000001, *string name);
public assertNumberEq(number expected, number actual, number epsilon = 0.0000000001, *string name);
public assertTrue(any actual, *string name);
public assertFalse(any actual, *string name);
public assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist args, *string name);
public assertThrows(string expectedErr, code theCode, *softlist args, *string name);
public assertSkip (*string name);
TestCase getTestCase(string meth);
public fail(*string msg);
public testNullAssertion(string name, code condition, *softlist args);
public any testAssertion(string name, code condition, *softlist args, int expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, float expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, number expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, bool expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, string expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, date expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, binary expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, hash expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, list expectedResultValue);
public any testAssertion(string name, code condition, *softlist args, QUnit::AbstractTestResult expectedResult = new QUnit::TestResultSuccess());
private any testAssertionIntern(TestCase tc, string name, QUnit::AbstractTestResult actualResult, QUnit::AbstractTestResult expectedResult, any ret, *string pos);
public testSkip(string reason);
//######## Test conditions passable to test assertions
bool equals(any a, any b);
bool notEquals(any a, any 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 p_argv, *hash opts) ;
setScriptPath(*string testedFile);
setUp() { }
tearDown() { }
private Program createInjectedProgram();
abstract performInjections(Program p);
abstract performModuleInjections();
private injectIntoModule(string module);
destructor();
int main();
};
class QUnit::DependencyInjectedTestRunner : public QUnit::Test {
public:
public setScriptPath(*string testedFile) {}
private injectIntoModule(string module) {}
constructor(string name, string version, *reference p_argv, *hash opts) ;
};
date
date date(date dt)
QUnit::TestResultExceptionRegexp::toString
public string toString()
returns a string describing the exception type
QUnit::TestResultExceptionDetail
Class representing Exception of a particular type with a particular detail message.
Definition: QUnit.qm.dox.h:168
QUnit::Test::assertEqSoft
public assertEqSoft(any expected, any actual, *string name)
Tests a value for equality to an expected value with soft comparisons (types may differ) ...
QUnit::TestResultValue
Class representing any non-boolean value.
Definition: QUnit.qm.dox.h:110
exp
number exp(number n)
QUnit::TestCase::m_name
string m_name
the name of the test case
Definition: QUnit.qm.dox.h:231
QUnit::TestReporter::addTestResult
addTestResult(TestCase tc, int success, *string error, *string pos, *string detail)
adds a test result
QUnit::TestResultExceptionRegexp::equals
public bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::DependencyInjectedTest
A class representing a test with injected dependencies.
Definition: QUnit.qm.dox.h:845
QUnit::TestResultPartialHashMatch
Class representing a partial match of a hash value. Common keys have to be identical.
Definition: QUnit.qm.dox.h:125
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:454
QUnit::TestReporter::OffsetColumn
const OffsetColumn
the default column offset for printing options used in printOption() and usageIntern() ...
Definition: QUnit.qm.dox.h:322
QUnit::Test::assertTrue
public assertTrue(any actual, *string name)
Tests a boolean value.
QUnit::Test::testNullAssertion
public testNullAssertion(string name, code condition, *softlist args)
Tests for a single assertion for a call returning no value (for example, to ensure that the call does...
QUnit::TestResultValue::equals
public 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:215
QUnit::TestResultExceptionType::equals
public bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::TestReporter::constructor
constructor(string name, string version, *reference p_argv, hash opts=Opts)
creates the object from the arguments
QUnit::AbstractTestResult
An abstract class representing test result interface.
Definition: QUnit.qm.dox.h:51
QUnit::TestResultExceptionType
Class representing Exception of a particular type.
Definition: QUnit.qm.dox.h:139
QUnit::TestReporter::num_asserts_skip
int num_asserts_skip
total number of skipped assertions in script
Definition: QUnit.qm.dox.h:350
QUnit::TestResultFailure::equals
public bool equals(QUnit::AbstractTestResult r)
Equality operator.
number
number number(softnumber n)
QUnit::Test::assertSkip
public assertSkip(*string name)
Skips assertion on purpose.
QUnit::TestCase::num_asserts
int num_asserts
number of assertions in current test case
Definition: QUnit.qm.dox.h:240
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::TestResultSuccess
Class representing boolean True.
Definition: QUnit.qm.dox.h:70
QUnit::TestResultExceptionDetail::toString
public string toString()
returns a string describing the exception type
QUnit::Test::equals
bool equals(any a, any b)
Compare two values for equality.
QUnit::TestReporter::num_asserts
int num_asserts
total number of assertions in script
Definition: QUnit.qm.dox.h:344
QUnit::Test::testAssertionValue
public any testAssertionValue(*string name, any actual, any expected)
Tests a value for equality to an expected value.
False
const False
QUnit::TestCase
Class containing the configuration for a test case.
Definition: QUnit.qm.dox.h:226
QUnit::TestResultExceptionType::m_exceptionType
string m_exceptionType
corresponds to the &quot;err&quot; key of an exception hash (the first value of a throw statement) ...
Definition: QUnit.qm.dox.h:144
QUnit::DependencyInjectedTest::setUp
setUp()
A prototype function.
Definition: QUnit.qm.dox.h:865
list
list list(...)
QUnit::Test::testAssertion
public any testAssertion(string name, code condition, *softlist args, int expectedResultValue)
Tests for a single assertion for a call returning an integer value and returns the value generated...
QUnit::TestResultExceptionType::toString
public string toString()
returns a string describing the exception type
QUnit::TestReporter::m_options
hash m_options
the result of parsing command-line options with Qore::GetOpt::parse2()
Definition: QUnit.qm.dox.h:336
QUnit::TestReporter
Base class for collecting test results and reporting.
Definition: QUnit.qm.dox.h:300
QUnit::TestCase::num_asserts_ok
int num_asserts_ok
number of successful assertions in current test case
Definition: QUnit.qm.dox.h:243
QUnit::TestResultExceptionDetail::constructor
constructor(string exceptionType, string exceptionDetail)
creates the object from the exception arguments
QUnit::TestResultExceptionType::constructor
constructor(string exceptionType)
creates the object from the exception arguments
QUnit::Test::printUnexpectedData
private string printUnexpectedData(any exp, any act, *bool neg, *bool soft_comparisons)
Helper function for printing out human-readable comparison of two values.
QUnit::Test::assertEq
public assertEq(any expected, any actual, *string name)
Tests a value for equality to an expected value with hard comparisons (types and values must be ident...
QUnit::Test::constructor
constructor(string name, string version, *reference p_argv, *hash opts)
creates the object and sets the name of the test
QUnit::TestReporter::m_printMethods
hash m_printMethods
A map of print methods, categorised into three types: header, summary, testreport.
Definition: QUnit.qm.dox.h:325
QUnit::Test::globalTearDown
globalTearDown()
global tear down; will be called once after all tests are run
Definition: QUnit.qm.dox.h:448
QUnit::Test::assertNumberEq
public assertNumberEq(number expected, number actual, number epsilon=0.0000000001, *string name)
Tests a number value for equality to an expected value with an allowed error.
QUnit::TestReporter::m_name
string m_name
test case name
Definition: QUnit.qm.dox.h:339
QUnit::TestResultExceptionSubstring::toString
public string toString()
returns a string describing the exception type
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::addTestCase
addTestCase(string name, code call, *softlist args)
adds a test case to run
QUnit::TestReporter::errors
int errors()
returns the number of errors encountered during test execution
QUnit::Test::assertFalse
public assertFalse(any actual, *string name)
Tests a boolean value.
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:341
type
string type(any arg)
QUnit::TestResultExceptionDetail::equals
public bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::TestResultExceptionRegexp
Class representing Exception of a particular type and matching regexp for detail. ...
Definition: QUnit.qm.dox.h:195
NOTHING
const NOTHING
QUnit::TestReporter::num_asserts_ok
int num_asserts_ok
total number of successful assertions in script
Definition: QUnit.qm.dox.h:347
QUnit::TestCase::checkException
checkException(QUnit::Test test, hash e)
handles exceptions raised while running the TestCase
QUnit::Test::getAssertionName
static string getAssertionName(*string name)
returns the assertion name for display purposes
QUnit::Test::fail
public fail(*string msg)
Fails the test unconditionally.
QUnit::Test::globalSetUp
globalSetUp()
global setup; will be called once before tests are run
Definition: QUnit.qm.dox.h:445
QUnit::TestCase::num_asserts_skip
int num_asserts_skip
number of skipped assertions in current test case
Definition: QUnit.qm.dox.h:246
QUnit::Test::regexpMatches
bool regexpMatches(string s, string regexp)
Compare a string for match against a regexp.
QUnit::Test::notEquals
bool notEquals(any a, any b)
Compare two values for inequality.
QUnit::Test::setUp
setUp()
Prototype function for setting up test environment. It will be called for each test individually...
Definition: QUnit.qm.dox.h:451
QUnit::Test::testCases
list testCases
list of test cases
Definition: QUnit.qm.dox.h:433
QUnit::TestCase::m_args
*list m_args
arguments to the above callable object
Definition: QUnit.qm.dox.h:237
QUnit::TestCase::run
run(QUnit::Test test)
runs the TestCase
QUnit::TestCase::constructor
constructor(string name, code code, *softlist args)
creates the TestCase object from the given arguments
QUnit::TestResultSuccess::equals
public bool equals(QUnit::AbstractTestResult r)
Equality operator.
QUnit::TestCase::m_code
code m_code
the body of the test case
Definition: QUnit.qm.dox.h:234
QUnit::Test::assertFloatEq
public assertFloatEq(float expected, float actual, float epsilon=0.0000000001, *string name)
Tests a float value for equality to an expected value with an allowed error.
QUnit::TestResultFailure
Class representing test function failure, both unspecific and with detail.
Definition: QUnit.qm.dox.h:85
QUnit::TestReporter::skipped
int skipped()
returns the number of tests skipped
QUnit::Test::getEnv
*string getEnv(string key, *string def)
facade for the system environment variables
hash
hash hash(object obj)
QUnit::TestReporter::Opts
const Opts
default options for Qore::GetOpt::constructor()
Definition: QUnit.qm.dox.h:356
QUnit::TestCase::rename
rename(string n_name)
renames the test case
QUnit::Test::testSkip
public testSkip(string reason)
Skips a given test, eg. because it may be missing some dependencies.
QUnit::TestReporter::testCount
int testCount()
returns the total number of test results
QUnit::Test::assertThrows
public assertThrows(string expectedErr, *string expectedDesc, code theCode, *softlist args, *string name)
Tests that a piece of code throws an exception with given description.
QUnit::Test
Base class representing a simple test, implements an implicit main() function and all utility functio...
Definition: QUnit.qm.dox.h:428