Module *m_test_suite* ********************** Documentation for the modules-m_test_suite module in */std/modules/m_test_suite.c*. Module Information ================== This module should be inherited by test suites, typically all located in */std/tests/*. It provides a lot of functions for queueing up tests, running them and various functions for cloning and testing the results. To write a test inherit this file, and write a function: .. code-block:: c inherit M_TEST_SUITE; void my_test() { return 1; } void init_tests() { add_test_true("Some test",(: my_test:)); } If you use ``add_test_true()`` the function succeeds if it returns 1 (anything that evaluates to true), and fails on 0. If you use ``add_test_fail()``, quite the opposite. This allows both to assume something fails and something succeeds. The test can be run by doing: ``unittest mytest`` If your file is called */std/tests/mytest.c* Functions ========= .. c:function:: object lab_clone(string file) Clones object from file argument and sends it to LAB room. The object is returned if cloned successfully. .. c:function:: object *std_clone(mixed *items) Clone and return a list of items from *^std/* If only one of them fails, an empty list is returned. .. c:function:: int std_clone_move(object ob, mixed items) Clones a list of items and moves them to ob. Returns true if all cloned and moved successfully, otherwise false. .. c:function:: varargs int inv_do(object who, string doo, string what, string check, int fail_on) Object ``who`` does ``do what``, e.g. troll does ``wear hat``. Function does a call_other to the ``what`` in inventory for function ``check``. Result of call_other will fail if value is fail_on. Example: .. code-block:: c inv_do(troll, "wield", "axe", "query_wielding", 0); Troll wields axe, and if ``axe->query_wielding() == 0`` we fail. If check is set to "gone", the test will return true if the object is gone. .. c:function:: varargs void add_test_true(string desc, function f, mixed args) Add a test to the queue that should be considered successful if it returns a value evaluating to true. .. code-block:: c add_test_true("Unwield longsword", ( : check_unwield, "sword" :)); add_test_true("Dualwield longsword", ( : check_dualwield, "longsword" :)); .. c:function:: varargs void add_test_fail(string desc, function f, mixed args) Add a test to the queue that should be considered successful if it returns a value evaluating to false. .. code-block:: c add_test_fail("Wield greataxe", ( : check_wield, "axe" :)); add_test_fail("Wield longsword", ( : check_wield, "longsword" :)); .. c:function:: void run_tests() Run all the tests added and report results. .. c:function:: void stat_me() Prints output about the test_suite. ``@./std/tests/horse->stat_me()`` e.g. *File generated by Lima 1.1a4 reStructured Text daemon.*