 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Eric Beyeler Guest
|
Posted: Thu Jul 15, 2004 11:53 pm Post subject: testing for compile-ability |
|
|
Is there any way with TMP or otherwise, to catch what would otherwise
be a compile error, and wrap it so it does not produce the error?
I am thinking in relation to unit tests, where a certain construct
should fail to compile, but testing for that failure prevents the test
suite from compiling and hence running. (I am writing a strong_typedef
template )
Eric B
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David Abrahams Guest
|
Posted: Fri Jul 16, 2004 11:06 am Post subject: Re: testing for compile-ability |
|
|
[email]ebeyeler_g (AT) yahoo (DOT) com[/email] (Eric Beyeler) writes:
| Quote: | Is there any way with TMP or otherwise, to catch what would otherwise
be a compile error, and wrap it so it does not produce the error?
|
Not at the language level.
| Quote: | I am thinking in relation to unit tests, where a certain construct
should fail to compile, but testing for that failure prevents the test
suite from compiling and hence running. (I am writing a strong_typedef
template )
|
The Boost build/test system includes "expected compilation failure"
tests for this purpose.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Michiel Salters Guest
|
Posted: Fri Jul 16, 2004 1:59 pm Post subject: Re: testing for compile-ability |
|
|
[email]ebeyeler_g (AT) yahoo (DOT) com[/email] (Eric Beyeler) wrote in message news:<8cfd9620.0407150446.1065b407 (AT) posting (DOT) google.com>...
| Quote: | Is there any way with TMP or otherwise, to catch what would otherwise
be a compile error, and wrap it so it does not produce the error?
I am thinking in relation to unit tests, where a certain construct
should fail to compile, but testing for that failure prevents the test
suite from compiling and hence running. (I am writing a strong_typedef
template )
|
Not in general, but SFINAE will allow a number of checks.
It cannot be used to check if a sequence of tokens can compile at all,
but it can be used to check if a syntactically valid template is
compilable for a certain set of parameters.
However, this is irrelevant for unit tests in C++. C++ has UB, which
must be handled from outside C++ anyway. On the outside, the test
fails if it doesn't run to completion, whether by measured failure,
UB or failure to compile.
Regards,
Michiel Salters
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Sat Jul 17, 2004 10:00 am Post subject: Re: testing for compile-ability |
|
|
Eric Beyeler wrote:
| Quote: |
Is there any way with TMP or otherwise, to catch what would otherwise
be a compile error, and wrap it so it does not produce the error?
I am thinking in relation to unit tests, where a certain construct
should fail to compile, but testing for that failure prevents the test
suite from compiling and hence running. (I am writing a strong_typedef
template )
|
This is what's known as a "negative test". You write one per source
file. If it compiles the test has succeeded (that is, it found an
error).
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|