Why are some test files 2 or 3 lines long?

wc -l test/unit/math/prim/mat/fun/*.cpp | sort -h | head

These files are basically empty until you get to diag_matrix_test.cpp:

     2 test/unit/math/prim/mat/fun/columns_dot_product_test.cpp
     2 test/unit/math/prim/mat/fun/Eigen_test.cpp
     2 test/unit/math/prim/mat/fun/log_determinant_test.cpp
     2 test/unit/math/prim/mat/fun/mdivide_left_tri_low_test.cpp
     2 test/unit/math/prim/mat/fun/mdivide_right_tri_low_test.cpp
     2 test/unit/math/prim/mat/fun/rows_dot_product_test.cpp
     3 test/unit/math/prim/mat/fun/dot_product_test.cpp
     3 test/unit/math/prim/mat/fun/LDLT_factor_test.cpp
     3 test/unit/math/prim/mat/fun/typedefs_test.cpp
     9 test/unit/math/prim/mat/fun/diag_matrix_test.cpp

These are all untested functions! They were probably created before we really started code reviewing pull requests. My guess is that there’s already open issues for these functions. Why these files even exist:

  1. At some point we introduced functions that couldn’t even be included, so we added these as a crude test. (Yes, we used to include code that couldn’t even be included at some point.)
  2. When we split tests into prim, rev, fwd, and mixed, I scripted it to split apart the tests into the different folders, even if there weren’t tests for the functions in question.

We could definitely use some help with testing. Even basic ones would be useful.

1 Like

I’ve started writing tests for these, should have a pr submitted soon. Will there be a test file (even if blank) for every function/distribution/etc., or are there going to be some that have no test at all? Is that something worth checking?


Thank you!!!

We’re trying to test every Stan-facing function (“public” isn’t the right term since we’re [almost] header-only). Univariate distributions have a test framework under test/prob so those are ok without individual test headers. I think everything else needs them.

That makes sense, thanks! After a quick look I can see there are a fair few without tests. I’ll start working through writing tests for the functions that don’t have any

I wish I could click on like more than once!

Make sure that the tests aren’t actually included in vectorized or higher-order tests. Sometimes there are tests in the mix/mat directory that cover all the other cases.