From 028635d6e8d1cfaf61b340dd907f71b8a2ed2871 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer <jpfeifer@gmx.de> Date: Mon, 20 Dec 2021 12:12:42 +0000 Subject: [PATCH] CONTRIBUTING.md: Fix wrong statements about unit tests --- CONTRIBUTING.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e498c5aa2..26d690a46 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,10 +102,10 @@ It's useful to contribute `.mod` files that test some aspect of Dynare that is n So-called unitary tests allow the test suite to check the correct functioning of the Matlab functions contained in Dynare. To add a unitary test you need to 1. add the keyword ` % --*-- Unitary tests --*--` at the end of the `function` header to tell the testsuite that the file contains unitary tests. -1. Add the particular tests at the end of the file (either after a `return` or the closing `end`) by - a. Starting a test with `%@test:INTEGER` - b. Adding a Matlab test code that provides a pass/fail indicator `T` that takes on `true` if the test passed. - c. Closing the test with `%@eof:INTEGER` +1. Add the particular tests at the end of the file after a `return` by + 1. Starting a test with `%@test:INTEGER` + 2. Adding a Matlab test code that provides a pass/fail indicator `T` that takes on `true` if the test passed. + 3. Closing the test with `%@eof:INTEGER` where `INTEGER` denotes the number of the test. An example testing the correct functionality of mode-computations for a normal distribution is @@ -113,7 +113,7 @@ An example testing the correct functionality of mode-computations for a normal d ``` function m = compute_prior_mode(hyperparameters,shape) % --*-- Unitary tests --*-- -end +return %@test:1 % Normal density @@ -130,3 +130,4 @@ end T = all(t); %@eof:1 ``` +You can also put a unit test after the closing `end`, but in this case you will need to preface each line with `%$`. See e.g. https://git.dynare.org/Dynare/dseries/-/commit/be4a4d39c125b92ee84ef876d86e6ec947c522b8 -- GitLab