added a failtest target to Makefile to test for the (expected) compilation failures
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60200 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -628,6 +628,23 @@ printfbench_printfbench.o: $(srcdir)/benchmarks/printfbench.cpp $(PRINTFBENCH_OD
|
|||||||
@COND_USE_STC_1@monolib_stc.o monodll_stc.o stcdll_stc.o stclib_stc.o: \
|
@COND_USE_STC_1@monolib_stc.o monodll_stc.o stcdll_stc.o stclib_stc.o: \
|
||||||
@COND_USE_STC_1@ $(srcdir)/include/wx/stc/stc.h
|
@COND_USE_STC_1@ $(srcdir)/include/wx/stc/stc.h
|
||||||
|
|
||||||
|
# notice the ugly hack with using CXXWARNINGS: we can't use CPPFLAGS as
|
||||||
|
# currently the value in the makefile would be ignored if we did, but
|
||||||
|
# warnings don't matter when we expect compilation to fail anyhow so we can
|
||||||
|
# use this variable to enable the compilation of code which is supposed to
|
||||||
|
# fail
|
||||||
|
failtest:
|
||||||
|
@$(RM) test_evthandler.o
|
||||||
|
@for d in GLOBAL STATIC METHOD FUNCTOR DERIVED WRONG_CLASS; do \
|
||||||
|
if $(MAKE) CXXWARNINGS=-DTEST_INVALID_BIND_$$d test_evthandler.o 2>/dev/null; then \
|
||||||
|
echo "*** Compilation with TEST_INVALID_BIND_$$d unexpectedly succeeded.">&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
.PHONY: failtest
|
||||||
|
|
||||||
# Include dependency info, if present:
|
# Include dependency info, if present:
|
||||||
@IF_GNU_MAKE@-include ./.deps/*.d
|
@IF_GNU_MAKE@-include ./.deps/*.d
|
||||||
|
|
||||||
|
@@ -366,20 +366,35 @@ void EvtHandlerTestCase::InvalidBind()
|
|||||||
// automatically, you need to uncomment them manually and test that
|
// automatically, you need to uncomment them manually and test that
|
||||||
// compilation does indeed fail
|
// compilation does indeed fail
|
||||||
|
|
||||||
//handler.Bind(MyEventType, GlobalOnAnotherEvent);
|
// connecting a handler with incompatible signature shouldn't work
|
||||||
//IdleFunctor f; handler.Bind(MyEventType, f);
|
#ifdef TEST_INVALID_BIND_GLOBAL
|
||||||
//handler.Bind(MyEventType, &MyHandler::StaticOnAnotherEvent);
|
handler.Bind(MyEventType, GlobalOnAnotherEvent);
|
||||||
//handler.Bind(MyEventType, &MyHandler::OnAnotherEvent, &handler);
|
#endif
|
||||||
|
#ifdef TEST_INVALID_BIND_STATIC
|
||||||
|
handler.Bind(MyEventType, &MyHandler::StaticOnAnotherEvent);
|
||||||
|
#endif
|
||||||
|
#ifdef TEST_INVALID_BIND_METHOD
|
||||||
|
handler.Bind(MyEventType, &MyHandler::OnAnotherEvent, &handler);
|
||||||
|
#endif
|
||||||
|
#ifdef TEST_INVALID_BIND_FUNCTOR
|
||||||
|
IdleFunctor f;
|
||||||
|
handler.Bind(MyEventType, f);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Test that this sample (discussed on the mailing list) doesn't compile:
|
// calling a derived class method with a base class pointer must not work
|
||||||
// >struct C1 : wxEvtHandler { };
|
#ifdef TEST_INVALID_BIND_DERIVED
|
||||||
// >struct C2 : wxEvtHandler { void OnWhatever(wxEvent&) };
|
struct C1 : wxEvtHandler { };
|
||||||
// >C1 c1;
|
struct C2 : wxEvtHandler { void OnWhatever(wxEvent&); };
|
||||||
// >c1.Connect(&C2::OnWhatever); // BOOM
|
C1 c1;
|
||||||
|
c1.Bind(&C2::OnWhatever);
|
||||||
|
#endif
|
||||||
|
|
||||||
//MySink mySink;
|
// using object pointer incompatible with the method must not work
|
||||||
//MyHandler myHandler;
|
#ifdef TEST_INVALID_BIND_WRONG_CLASS
|
||||||
//myHandler.Bind( MyEventType, &MyHandler::OnMyEvent, &mySink );
|
MySink mySink;
|
||||||
|
MyHandler myHandler;
|
||||||
|
myHandler.Bind(MyEventType, &MyHandler::OnMyEvent, &mySink);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !wxEVENTS_COMPATIBILITY_2_8
|
#endif // !wxEVENTS_COMPATIBILITY_2_8
|
||||||
|
@@ -168,5 +168,23 @@
|
|||||||
<wx-lib>base</wx-lib>
|
<wx-lib>base</wx-lib>
|
||||||
</exe>
|
</exe>
|
||||||
|
|
||||||
|
<fragment format="autoconf">
|
||||||
|
# notice the ugly hack with using CXXWARNINGS: we can't use CPPFLAGS as
|
||||||
|
# currently the value in the makefile would be ignored if we did, but
|
||||||
|
# warnings don't matter when we expect compilation to fail anyhow so we can
|
||||||
|
# use this variable to enable the compilation of code which is supposed to
|
||||||
|
# fail
|
||||||
|
failtest:
|
||||||
|
@$(RM) test_evthandler.o
|
||||||
|
@for d in GLOBAL STATIC METHOD FUNCTOR DERIVED WRONG_CLASS; do \
|
||||||
|
if $(MAKE) CXXWARNINGS=-DTEST_INVALID_BIND_$$d test_evthandler.o 2>/dev/null; then \
|
||||||
|
echo "*** Compilation with TEST_INVALID_BIND_$$d unexpectedly succeeded.">&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
.PHONY: failtest
|
||||||
|
</fragment>
|
||||||
|
|
||||||
</makefile>
|
</makefile>
|
||||||
|
Reference in New Issue
Block a user