Boost logo

Boost :

Subject: Re: [boost] Unittest capability for meta-programs feedback request
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-09-27 10:59:31


on Tue Sep 27 2011, Ben Robinson <icaretaker-AT-gmail.com> wrote:

> This submission would make it possible to write a complete set of unit
> tests for meta-programs, to test both the positive, compiling statements,
> and the negative, non-compiling statements. These tests will all compile,
> and the negative tests can throw an exception instead of failing to
> compile.

I think you're over-promising here. You can't turn all non-compiling
code into compiling code by wrapping it in something. Some errors are
hard errors and there's nothing you can do about it without modifying
the code. If I write a metaprogram component that is designed to
generate a compilation error if it is mis-used, and then I write a test
to prove that it does generate that compilation error, and you can
somehow turn that into a test that throws without modifying my
component... you are a god. [You may still be a god, but not because
you solved this problem ;-)]

I think what you mean to say is that it tests both positive and negative
assertions without responding to failed assertions by generating a
compilation error.

Personally I am very uncomfortable with the use of exceptions to deal
with failed assertions, and in a test that's just a bunch of
compile-time assertions, I don't see *any* advantage whatsoever in using
exceptions.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk