1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/project_with_tests_for_main
2023-02-13 10:29:02 +02:00
..
main.v tests: fix warnings when doing ./v -W -progress -check-syntax test-fixed 2020-10-26 14:41:57 +02:00
my_other_test.v ci: vet all files from the compiler (#5994) 2020-07-27 12:15:29 +02:00
my_test.v ci: vet all files from the compiler (#5994) 2020-07-27 12:15:29 +02:00
README.md docs: unify format of notes (#17294) 2023-02-13 10:29:02 +02:00
v.mod

This folder contains a V project, intended to be used as a demonstration for how to test functions defined inside a main module.

See my_test.v and my_other_test.v . These files work as any other internal module tests, i.e. they do module main at their top, so that v knows, that they are internal tests, and for which module they apply.

When you do v my_test.v, v will try to find other *.v files in the same folder that also have module main at their top, then it will process them and process the my_test.v file too.

The v fn main(){} function that you most likely also have will get compiled as normal to void main__main(){...}, but it will NOT be called by anything, so it will not mess up your tests.

Instead, your test_ functions will get called inside the generated int main(){...} test runner, just like it is the case with all _test.v files (internal or external ones).

Note Each _test.v file is compiled separately from all other test.v files, so you can have conflicting test functions in them without a problem too.