From bcdf1b95c1216487ec48644de42eb892929b3add Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 19 Dec 2022 13:15:39 +0200 Subject: [PATCH] docs: add a note about test files being compiled as separate V programs, independently from normal code --- doc/docs.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 4054d42e8..66bd49744 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -4291,9 +4291,14 @@ fn test_hello() { assert hello() == 'Hello world' } ``` -To run the test above, use `v hello_test.v`. This will check that the function `hello` is +To run the test file above, use `v hello_test.v`. This will check that the function `hello` is producing the correct output. V executes all test functions in the file. +Note: all `_test.v` files (both external and internal ones), are compiled as *separate programs*. +In other words, you may have as many `_test.v` files, and tests in them as you like, they will +not affect the compilation of your other code in `.v` files normally at all, but only when you +do explicitly `v file_test.v` or `v test .`. + * All test functions have to be inside a test file whose name ends in `_test.v`. * Test function names must begin with `test_` to mark them for execution. * Normal functions can also be defined in test files, and should be called manually. Other @@ -6468,4 +6473,4 @@ Assignment Operators += -= *= /= %= &= |= ^= >>= <<= >>>= -``` \ No newline at end of file +``` -- 2.30.2