Awkl
Loading...
Searching...
No Matches
test Namespace Reference

Functions

unassigned import ()
 Import functions as strings in the awk namespace.
 
unassigned add (string|array< string > names)
 Add tests' names to be run.
 
unassigned printSummary ()
 Print the tests summary.
 
bool testOne (string tname)
 Run a single test in a test set.
 
auto runTests (string|array< string > names, number exit_f=0, number import_f=1) -> bool|never
 Run a set of tests.
 
unassigned it (string d)
 Set a description for the current test.
 
unassigned _assert (any x, string msg_ok, string msg_bad)
 Underlying assert function.
 
unassigned assertTruthy (any x)
 Assert whether a variable is truthy.
 
unassigned assertFalsy (any x)
 Assert whether a variable is falsy.
 
unassigned assertTrue (any x)
 Assert whether a variable is true (number|bool 1)
 
unassigned assertFalse (any x)
 Assert whether a variable is true (number|bool 0)
 
unassigned assert (any x)
 Alias for test::assertTruthy
 
unassigned assertOp (any x, any e, string op, string sym, string pre, string post)
 Assert whether a binary operation on two variables is truthy.
 
unassigned assertOpTrue (any x, any e, string op, string sym)
 Assert whether a binary operation on two variables is truthful.
 
unassigned assertEq (scalar x, scalar e)
 Assert whether a variable is equal to another.
 
unassigned assertEq (array X, array E)
 Assert whether all elements in an array are equal to the ones in another.
 
unassigned assertNe (scalar x, scalar e)
 Assert whether a variable is not equal to another.
 
unassigned assertNe (array X, array E)
 Assert whether all elements in an array are not equal to the ones in another.
 
unassigned assertLt (scalar x, scalar e)
 Assert whether a variable is less than another.
 
unassigned assertLt (array X, array E)
 Assert whether all elements in an array are less than the ones in another.
 
unassigned assertLe (scalar x, scalar e)
 Assert whether a variable is less than or equal another.
 
unassigned assertLe (array X, array E)
 Assert whether all elements in an array are less than or equal to the ones in another.
 
unassigned assertGt (scalar x, scalar e)
 Assert whether a variable is greater than another.
 
unassigned assertGt (array X, array E)
 Assert whether all elements in an array are greater than the ones in another.
 
unassigned assertGe (scalar x, scalar e)
 Assert whether a variable is greater than or equal another.
 
unassigned assertGe (array X, array E)
 Assert whether all elements in an array are greater than or equal to the ones in another.
 
unassigned assertMatch (scalar x, scalar e)
 Assert whether a variable matches a regular expression.
 
unassigned assertMatch (array X, array E)
 Assert whether all elements in an array match a regular expression.
 
unassigned assertNomatch (scalar x, scalar e)
 Assert whether a variable does not match a regular expression.
 
unassigned assertNomatch (array X, array E)
 Assert whether all elements in an array do not match a regular expression.
 
unassigned assertApprox (number x, number e, numeric rt=0.01, numeric at=0.00)
 Assert whether a variable is approximately equal to another.
 
unassigned assertApprox (array X, array E, numeric rt=0.01, numeric at=0.00)
 Assert whether all elements in an array are approximately equal to the ones in another.
 
unassigned assertInside (any x, array A)
 Assert whether a variable is an element of an array.
 
unassigned assertContains (array A, any x)
 Assert whether an array contains an element.
 
unassigned assertSetInside (scalar x, set A)
 Assert whether a variable is an element of a set.
 
unassigned assertSetInside (set A, set B)
 Assert whether a set is a (non-strict) subset of another.
 
unassigned assertSetContains (set A, scalar x)
 Assert whether a set contains an element.
 
unassigned assertSetContains (set A, set B)
 Assert whether a set is a (non-strict) superset of another.
 
unassigned assertType (any x, string type)
 Assert whether variable is of a specific type.
 

Variables

number conf ["assertion"]["print"] = 0
 

Function Documentation

◆ _assert()

unassigned test::_assert ( any x,
string msg_ok,
string msg_bad )

Underlying assert function.

Parameters
xValue to check for its truthyness
msg_okText for showing on a successful assertion
msg_badText for showing on a failed assertion
Returns

◆ add()

unassigned test::add ( string|array< string > names)

Add tests' names to be run.

Parameters
namesTests' names to add, without their test_ prefix
Returns

◆ assert()

unassigned test::assert ( any x)

Alias for test::assertTruthy

Parameters
x
Returns

◆ assertApprox() [1/2]

unassigned test::assertApprox ( array X,
array E,
numeric rt = 0.01,
numeric at = 0.00 )

Assert whether all elements in an array are approximately equal to the ones in another.

Parameters
XArray of variables to check
EArray of expected approximate values
rtRelative tolerance
atAbsolute tolerance
Returns

◆ assertApprox() [2/2]

unassigned test::assertApprox ( number x,
number e,
numeric rt = 0.01,
numeric at = 0.00 )

Assert whether a variable is approximately equal to another.

Parameters
xVariable to check
eExpected approximate value
rtRelative tolerance
atAbsolute tolerance
Returns
Examples
test_basic.awk.

◆ assertContains()

unassigned test::assertContains ( array A,
any x )

Assert whether an array contains an element.

Parameters
AContaining array
xValue to check its inclusion
Returns

◆ assertEq() [1/2]

unassigned test::assertEq ( array X,
array E )

Assert whether all elements in an array are equal to the ones in another.

Parameters
XArray of variables to check
EArray of expected values
Returns

◆ assertEq() [2/2]

unassigned test::assertEq ( scalar x,
scalar e )

Assert whether a variable is equal to another.

Parameters
xVariable to check
eExpected value
Returns
Examples
test_basic.awk.

◆ assertFalse()

unassigned test::assertFalse ( any x)

Assert whether a variable is true (number|bool 0)

Parameters
xVariable to check for its falseness
Returns
Examples
test_basic.awk.

◆ assertFalsy()

unassigned test::assertFalsy ( any x)

Assert whether a variable is falsy.

Parameters
xVariable to check for its falsyness
Returns
Examples
test_basic.awk.

◆ assertGe() [1/2]

unassigned test::assertGe ( array X,
array E )

Assert whether all elements in an array are greater than or equal to the ones in another.

Parameters
XLeft array
ERight array
Returns

◆ assertGe() [2/2]

unassigned test::assertGe ( scalar x,
scalar e )

Assert whether a variable is greater than or equal another.

Parameters
xLeft operand
eRight operand
Returns

◆ assertGt() [1/2]

unassigned test::assertGt ( array X,
array E )

Assert whether all elements in an array are greater than the ones in another.

Parameters
XLeft array
ERight array
Returns

◆ assertGt() [2/2]

unassigned test::assertGt ( scalar x,
scalar e )

Assert whether a variable is greater than another.

Parameters
xLeft operand
eRight operand
Returns

◆ assertInside()

unassigned test::assertInside ( any x,
array A )

Assert whether a variable is an element of an array.

Parameters
xVariable to check its inclusion
AContaining array
Returns

◆ assertLe() [1/2]

unassigned test::assertLe ( array X,
array E )

Assert whether all elements in an array are less than or equal to the ones in another.

Parameters
XLeft array
ERight array
Returns

◆ assertLe() [2/2]

unassigned test::assertLe ( scalar x,
scalar e )

Assert whether a variable is less than or equal another.

Parameters
xLeft operand
eRight operand
Returns

◆ assertLt() [1/2]

unassigned test::assertLt ( array X,
array E )

Assert whether all elements in an array are less than the ones in another.

Parameters
XLeft array
ERight array
Returns

◆ assertLt() [2/2]

unassigned test::assertLt ( scalar x,
scalar e )

Assert whether a variable is less than another.

Parameters
xLeft operand
eRight operand
Returns

◆ assertMatch() [1/2]

unassigned test::assertMatch ( array X,
array E )

Assert whether all elements in an array match a regular expression.

Parameters
XArray of variables to check
EArray of regular expressions to match against
Returns

◆ assertMatch() [2/2]

unassigned test::assertMatch ( scalar x,
scalar e )

Assert whether a variable matches a regular expression.

Parameters
xVariable to check
eRegular expression to match against
Returns

◆ assertNe() [1/2]

unassigned test::assertNe ( array X,
array E )

Assert whether all elements in an array are not equal to the ones in another.

Parameters
XLeft array
ERight array
Returns

◆ assertNe() [2/2]

unassigned test::assertNe ( scalar x,
scalar e )

Assert whether a variable is not equal to another.

Parameters
xLeft operand
eRight operand
Returns
Examples
test_basic.awk.

◆ assertNomatch() [1/2]

unassigned test::assertNomatch ( array X,
array E )

Assert whether all elements in an array do not match a regular expression.

Parameters
XArray of variables to check
EArray of regular expressions to match against
Returns

◆ assertNomatch() [2/2]

unassigned test::assertNomatch ( scalar x,
scalar e )

Assert whether a variable does not match a regular expression.

Parameters
xVariable to check
eRegular expression to match against
Returns

◆ assertOp()

unassigned test::assertOp ( any x,
any e,
string op,
string sym,
string pre,
string post )

Assert whether a binary operation on two variables is truthy.

Parameters
xLeft operand
eRight operand
opOperation: a function name
symSymbol denoting the operation
pre
post
Returns

◆ assertOpTrue()

unassigned test::assertOpTrue ( any x,
any e,
string op,
string sym )

Assert whether a binary operation on two variables is truthful.

Parameters
xLeft operand
eRight operand
opOperation: a function name
symSymbol denoting the operation
Returns

◆ assertSetContains() [1/2]

unassigned test::assertSetContains ( set A,
scalar x )

Assert whether a set contains an element.

Parameters
AContaining set
xVariable to check its inclusion
Returns

◆ assertSetContains() [2/2]

unassigned test::assertSetContains ( set A,
set B )

Assert whether a set is a (non-strict) superset of another.

Parameters
AContaining set
BSet to check for its inclusion
Returns

◆ assertSetInside() [1/2]

unassigned test::assertSetInside ( scalar x,
set A )

Assert whether a variable is an element of a set.

Parameters
xVariable to check for its inclusion
AContaining set
Returns

◆ assertSetInside() [2/2]

unassigned test::assertSetInside ( set A,
set B )

Assert whether a set is a (non-strict) subset of another.

Parameters
ASet to check for its inclusion
BContaining set
Returns

◆ assertTrue()

unassigned test::assertTrue ( any x)

Assert whether a variable is true (number|bool 1)

Parameters
xVariable to check for its truthfulness
Returns
Examples
test_basic.awk.

◆ assertTruthy()

unassigned test::assertTruthy ( any x)

Assert whether a variable is truthy.

Parameters
xVariable to check for its truthyness
Returns
Examples
test_basic.awk.

◆ assertType()

unassigned test::assertType ( any x,
string type )

Assert whether variable is of a specific type.

Parameters
xVariable to check its type
typeType name
Returns
Examples
test_basic.awk.

◆ import()

unassigned test::import ( )

Import functions as strings in the awk namespace.

Returns

◆ it()

unassigned test::it ( string d)

Set a description for the current test.

Parameters
dDescription text for the current test
Returns
Examples
test_basic.awk.

◆ printSummary()

unassigned test::printSummary ( )

Print the tests summary.

Returns

◆ runTests()

auto test::runTests ( string|array< string > names,
number exit_f = 0,
number import_f = 1 ) -> bool | never

Run a set of tests.

Parameters
namesNames of tests to be run. Optional. If ommited, functions starting with test_ are considered
exit_fWhether to exit at the end of testing
import_fWhether to automatically import functions to the awk namespace
Returns
True if the set of tests was successful, false if it failed. Or exits with exit status 0 if the set of tests was succesful or with 1 if it failed
Examples
test_basic.awk.

◆ testOne()

bool test::testOne ( string tname)

Run a single test in a test set.

Parameters
tnameFull name of the current test function
Returns
True if the current test was successful, false if it failed

Variable Documentation

◆ conf

string test::conf = 0