[vvhitespace] / tests /
drwxr-xr-x   ..
-rw-r--r-- 278 0001_push_printchar_exit.pvvs
-rw-r--r-- 158 1001_stack_push.pvvs
-rw-r--r-- 238 1002_stack_dup.pvvs
-rw-r--r-- 277 1003_stack_swap.pvvs
-rw-r--r-- 233 1004_stack_drop.pvvs
-rw-r--r-- 223 2001_arithmetic_addition.pvvs
-rw-r--r-- 231 2002_arithmetic_subtraction.pvvs
-rw-r--r-- 224 2003_arithmetic_multiplication.pvvs
-rw-r--r-- 217 2004_arithmetic_division.pvvs
-rw-r--r-- 991 2005_arithmetic_remainder.pvvs
-rw-r--r-- 473 3001_heap.pvvs
-rw-r--r-- 89 4001_flowcontrol_exit.pvvs
-rw-r--r-- 348 4002_flowcontrol_unconditional_jump_to_label.pvvs
-rw-r--r-- 333 4003_flowcontrol_jump_if_tos_is_zero.pvvs
-rw-r--r-- 337 4004_flowcontrol_jump_if_tos_is_negative.pvvs
-rw-r--r-- 280 4005_flowcontrol_jump_to_subroutine.pvvs
-rw-r--r-- 266 4006_flowcontrol_return_from_subroutine.pvvs
-rw-r--r-- 493 4100_flowcontrol_branches_not_taken.pvvs
-rw-r--r-- 181 5001_io_output_character.pvvs
-rw-r--r-- 162 5002_io_output_digit.pvvs
-rw-r--r-- 264 5003_io_input_character.pvvs
-rw-r--r-- 252 5004_io_input_digit.pvvs
-rw-r--r-- 760 6001_push_intmin.pvvs
-rw-r--r-- 200 Makefile
-rw-r--r-- 2945 README.md
-rwxr-xr-x 2470 vv_test.py

Overview

This folder contains tests for the VVhitespace interpreter (vvi).

Instructions

Edit the shebang in vv_test.py to match your environment. For example:

FreeBSD 12: #!/usr/local/bin/python3.6
Debian 9  : #!/usr/bin/python3

Build vvc and vvi in the source tree, if you haven’t already.

vvs-repo/tests % cd .. && make clean all && cd tests
cc -Wall -std=c99 -o vvc vv_compiler.c
cc -Wall -std=c99 -o vvi vv_interpreter.c
vvs-repo/tests %

Alternatively, edit the configuration block in vv_test.py to provide appropriate paths relative to this tests folder.

compiler_path = '../vvc'
interpreter_path = '../vvi'

With configuration now complete, execute the tests via make test. A dot will appear for every successfully completed test. For example:

vvs-repo/tests % make test
Testing vvi:
.......................
vvs-repo/tests %

If a test should fail, the name of the test will be printed in place of its dot. For example, with an induced failure in the division command:

vvs-repo/tests % make test
Testing vvi:
........
2004_arithmetic_division
    Expected: A
    Received: A113
..............
vvs-repo/tests %

If testing is aborted prematurely, say by a Ctrl-C initiated SIGINT, use make clean to remove any temporary files.

Add New Test

Consider the test 5003_io_input_character.pvvs as an example, reproduced below with line numbers.

1:  SSSTN           | ST: Push +1
2:  TNTS            | IO: Input character
3:  SSSTN           | ST: Push +1
4:  TTT             | HP: Load
5:  TNSS            | IO: Output character
6:  NNN             | FC: Terminate program

With the goal of testing the get character from user instruction, the test begins on lines 1-2 by setting up for and then using this instruction. Lines 3-5 print the result and line 6 terminates the test.

Once you have written a test of this form, add it to the tests array in the file vv_test.py. The three fields are:

['filename_without_extension', 'string for stdin', 'string for expected stdout']

Continuing the same example:

['5003_io_input_character', 'A', 'A'],

Note that the first field was the name of the file in which our test was saved, minus the extension. These filenames should be numbered, grouped by category and ordered by dependency.

The second field is a string from which our test program may read. Since this is a test of reading an input character, the string is populated with A.

The final field is the expected output from our test. In this example, this is simply the same character that was read from the previous field, A.

Each time the test is executed by vv_test.py it will be fed the input from the second field and the output will be compared against the third field. If there is any mismatch, the test has failed and the user will be alerted with an error.