brunocodutra / metal

Love template metaprogramming
https://brunocodutra.github.io/metal/
MIT License
325 stars 23 forks source link

Why is METAL_TEST_GEN_LIMIT set to 9? #106

Closed ecrypa closed 5 years ago

ecrypa commented 5 years ago

For testing, I see values and expressions being defined from 0 to 9. As far as I understand the preprocessor voodoo, METAL_TEST_GEN_LIMIT needs to be set to 10 in order to make use of all definitions from above. So why is METAL_TEST_GEN_LIMIT set to 9?

This came to my mind when wondering why #104 does not cause any test failures.

I tried to set METAL_TEST_GEN_LIMIT to 10, but I was not able to understand and adjust test.unit.metal.list.accumulate. Those INC there exclude the expr0 from testing, right?

brunocodutra commented 5 years ago

The reason why it's limited to 9, is that many test definitions depend on INC, which is arbitrarily only defined until 8. See metal::arg tests for example, which uses INC to skip M = 0, for which metal::arg<M> is not defined. This does mean that not every test definition makes use of the full range of test data, but that's not necessarily a bad thing.

GEN(MATRIX) is defined such that it substitutes MATRIX(M, N) for all values in the range [0, METAL_TEST_GEN_LIMIT - 1], if you set METAL_TEST_GEN_LIMIT=10, even if you extend INC such that it's defined for 9, tests will still fail because they will try to reference, say VALUE(INC(9)), which is not defined.

ecrypa commented 5 years ago

Thanks for the explanation. From my point of view, this can be closed.