C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

testing for compile-ability

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Eric Beyeler
Guest





PostPosted: Thu Jul 15, 2004 11:53 pm    Post subject: testing for compile-ability Reply with 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 )

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





PostPosted: Fri Jul 16, 2004 11:06 am    Post subject: Re: testing for compile-ability Reply with quote



[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





PostPosted: Fri Jul 16, 2004 1:59 pm    Post subject: Re: testing for compile-ability Reply with quote



[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





PostPosted: Sat Jul 17, 2004 10:00 am    Post subject: Re: testing for compile-ability Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.