LSL-PyOptimizer/unit_tests
Sei Lisa 1d6bb809bf Fix bug in llListSortStrided producing incorrect results sometimes
It used `a = lst[i]` instead of taking the stride index into account (that is, it should have been `a = lst[i+idx]`). Anyway, the exact same value is in b, so use that instead.

Test case by Tapple Gao.
2024-10-09 01:40:19 +02:00
..
coverage.suite Fix missing comma that prevented --libdata from working 2022-12-20 21:49:32 +01:00
expr.suite Fix bug in llListSortStrided producing incorrect results sometimes 2024-10-09 01:40:19 +02:00
lso.suite LSO no longer returns -1 for llListFindList([], []) 2024-04-18 19:24:32 +02:00
preproc.suite Fix --postarg and add option --preproc-show-cmdline + unit test 2022-06-17 16:13:22 +02:00
regression.suite Parser fix: Give error in state switch when ident is not a state 2024-05-25 20:04:33 +02:00
__init__.py Forgot unit_tests/__init__.py necessary to run the JSON test 2019-01-11 17:34:10 +01:00
builtins-coverage-1.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
builtins-coverage-2.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
builtins-coverage-4.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
builtins-coverage-5.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
cat.py Add the new test suite. 2019-01-04 20:27:36 +01:00
false.py Add the new test suite. 2019-01-04 20:27:36 +01:00
fndata-coverage-3.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
fndata-coverage-4.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
fndata-coverage-5.txt Add the new test suite. 2019-01-04 20:27:36 +01:00
json.err All tests pass now 2020-11-10 02:14:15 +01:00
json.out Add the new test suite. 2019-01-04 20:27:36 +01:00
json.py All tests pass now 2020-11-10 02:14:15 +01:00
output-list.lsl Remove indents from list generator 2021-05-08 18:45:15 +02:00
README.txt Make .fail files replace the docstring in order to be visible 2019-01-04 22:29:15 +01:00
seftable-coverage.txt Add the new test suite. 2019-01-04 20:27:36 +01:00

Unit testing suites. These tests are run via run-tests.py.

The testing is performed using the standard Python module 'unittest'. This module accepts some command-line options; we don't add any ourselves. Use 'python run-tests.py -h' for help, or look here for details: https://docs.python.org/2/library/unittest.html#command-line-interface

There are 5 directories defined in the code that contain tests, all of which end in .suite: regression.suite, expr.suite, lso.suite, coverage.suite, preproc.suite.

The files that all 5 contain are the tests themselves. The run-tests.py program reads all .run and .lsl files in each directory and takes them as tests to run.

A test is a series of files all with the same name and with different extensions. Running the test means running the optimizer with the parameters in the .run file (if present), giving it the .lsl file (if present) as input. The output to stdout is compared to the .out file and the output to stderr is compared to the .err file. The test passes if both match and no exception is raised; otherwise it fails.

These are the extensions that the test suite recognizes in more detail:

  .lsl: Source file to test. If the first line starts with '// ', then the text in the rest of the line will be set as the docstring for the corresponding test function (visible when requesting verbose coverage).
  .run: Command line parameters for the test. Default is: 'main.py -', except in expr.suite which defaults to 'main.py -O clear,optimize,constfold,addstrings,expr -'. The syntax for the parameters is that of the Bourne shell, but '$' expansion is not supported. The 'main.py' part is the value that argv[0] will receive, but is unused otherwise.
  .out: Expected stdout resulting from the test. If the first line is REGEX then the rest of the file will be taken as a regular expression to match against, as opposed to matching the whole file contents.
  .err: Expected stderr resulting from the test. It also allows regular expression.
  .skp: If present, the test will be skipped (not run). The contents of this file are taken as the reason for the expected failure.
  .fail: If present, the test will be run, and counted as an expected failure. If a .fail file is present and the test passes, that will be counted as an unexpected success, and the program will not report success at the end. The contents will go to the docstring for the test if not empty, replacing the one taken from the .lsl file.

A test is considered such when either the .lsl or the .run file are present. The default stdin for the program is the .lsl file.

As for the meaning of each subdirectory:

- regression.suite contains normal regression tests.
- expr.suite contains regression tests that apply to expressions.
- lso.suite contains LSO mode tests. Note that LSO support is incomplete.
- coverage.suite contains tests that force certain code paths to execute, in order to maximize the exercised code coverage, even if some tests are trivial and unlikely to cause a regression.
- preproc.suite is for preprocessor-related tests.

As for the files in this directory:

- cat.py just copies standard input to standard output. Used as a preprocessor for some preprocessor tests.
- false.py just terminates with exit code 1.
- output-list.lsl is a utility script that dumps an arbitrary list to local chat, in a format very similar to the one that the expression suite outputs (it may require manual removal of timestamps). Float precision may differ.