astyle --style=ansi

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@663 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2006-06-01 12:35:08 +00:00
parent 50d35c6196
commit 2a5dc20f8a

View file

@ -25,172 +25,181 @@
void free_function(bool &result) void free_function(bool &result)
{ {
result=true; result=true;
} }
class FunctorTest : public Test class FunctorTest : public Test
{ {
public: public:
FunctorTest() : Test("Functor.h") {} FunctorTest() : Test("Functor.h")
{}
virtual void execute(TestResult &result) virtual void execute(TestResult &result)
{ {
printName(result); printName(result);
using namespace Loki; using namespace Loki;
bool r; bool r;
TestFunctor testFunctor; TestFunctor testFunctor;
TestClass testClass; TestClass testClass;
#ifndef LOKI_DISABLE_TYPELIST_MACROS #ifndef LOKI_DISABLE_TYPELIST_MACROS
Functor<void,LOKI_TYPELIST_1(bool &)> function(testFunction);
Functor<void,LOKI_TYPELIST_1(bool &)> function2(testFunction);
Functor<void,LOKI_TYPELIST_1(bool &)> functor(testFunctor);
Functor<void,LOKI_TYPELIST_1(bool &)> functor2(testFunctor);
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor(&testClass,&TestClass::member);
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor2(&testClass,&TestClass::member);
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy(function);
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy2(function);
Functor<void,NullType> bindFunctor(BindFirst(function,testResult)); Functor<void,LOKI_TYPELIST_1(bool &)> function(testFunction);
Functor<void,NullType> bindFunctor2(BindFirst(function,testResult)); Functor<void,LOKI_TYPELIST_1(bool &)> function2(testFunction);
Functor<void,LOKI_TYPELIST_1(bool &)> functor(testFunctor);
Functor<void,LOKI_TYPELIST_1(bool &)> functor2(testFunctor);
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor(&testClass,&TestClass::member);
Functor<void,LOKI_TYPELIST_1(bool &)> classFunctor2(&testClass,&TestClass::member);
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy(function);
Functor<void,LOKI_TYPELIST_1(bool &)> functorCopy2(function);
Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor)); Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
Functor<void> chainFunctor2(Chain(bindFunctor,bindFunctor)); Functor<void,NullType> bindFunctor2(BindFirst(function,testResult));
Functor<void,LOKI_TYPELIST_1(bool &)> member_func(&testClass,&TestClass::member); Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
Functor<void,LOKI_TYPELIST_1(bool &)> free_func(&free_function); Functor<void> chainFunctor2(Chain(bindFunctor,bindFunctor));
Functor<void,LOKI_TYPELIST_1(bool &)> NULL_func;
Functor<void,LOKI_TYPELIST_1(bool &)> NULL_func0; Functor<void,LOKI_TYPELIST_1(bool &)> member_func(&testClass,&TestClass::member);
Functor<void,LOKI_TYPELIST_1(bool &)> free_func(&free_function);
Functor<void,LOKI_TYPELIST_1(bool &)> NULL_func;
Functor<void,LOKI_TYPELIST_1(bool &)> NULL_func0;
#else #else
Functor<void,Seq<bool &> > function(testFunction);
Functor<void,Seq<bool &> > function2(testFunction); Functor<void,Seq<bool &> > function(testFunction);
Functor<void,Seq<bool &> > functor(testFunctor); Functor<void,Seq<bool &> > function2(testFunction);
Functor<void,Seq<bool &> > functor2(testFunctor); Functor<void,Seq<bool &> > functor(testFunctor);
Functor<void,Seq<bool &> > classFunctor(&testClass,&TestClass::member); Functor<void,Seq<bool &> > functor2(testFunctor);
Functor<void,Seq<bool &> > classFunctor2(&testClass,&TestClass::member); Functor<void,Seq<bool &> > classFunctor(&testClass,&TestClass::member);
Functor<void,Seq<bool &> > functorCopy(function); Functor<void,Seq<bool &> > classFunctor2(&testClass,&TestClass::member);
Functor<void,Seq<bool &> > functorCopy2(function); Functor<void,Seq<bool &> > functorCopy(function);
//TODO: Functor<void,Seq<bool &> > functorCopy2(function);
//Functor<void,NullType> bindFunctor(BindFirst(function,testResult)); //TODO:
//Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor)); //Functor<void,NullType> bindFunctor(BindFirst(function,testResult));
//Functor<void> chainFunctor(Chain(bindFunctor,bindFunctor));
#endif #endif
testResult=false; testResult=false;
function(testResult); function(testResult);
bool functionResult=testResult; bool functionResult=testResult;
testResult=false; testResult=false;
functor(testResult); functor(testResult);
bool functorResult=testResult; bool functorResult=testResult;
testResult=false; testResult=false;
classFunctor(testResult); classFunctor(testResult);
bool classFunctorResult=testResult; bool classFunctorResult=testResult;
testResult=false; testResult=false;
functorCopy(testResult); functorCopy(testResult);
bool functorCopyResult=testResult; bool functorCopyResult=testResult;
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE #ifdef LOKI_FUNCTORS_ARE_COMPARABLE
bool functionCompare = function==function2; bool functionCompare = function==function2;
bool functorCompare = functor!=functor2; // is this a bug? bool functorCompare = functor!=functor2; // is this a bug?
bool classFunctorCompare = classFunctor==classFunctor2; bool classFunctorCompare = classFunctor==classFunctor2;
bool functorCopyCompare = functorCopy==functorCopy2; bool functorCopyCompare = functorCopy==functorCopy2;
bool free_mem = free_func!=member_func; bool free_mem = free_func!=member_func;
bool mem_free = member_func!=free_func; bool mem_free = member_func!=free_func;
bool null0 = NULL_func == NULL_func0; bool null0 = NULL_func == NULL_func0;
bool null1 = NULL_func != free_func; bool null1 = NULL_func != free_func;
bool null2 = NULL_func != member_func; bool null2 = NULL_func != member_func;
bool null3 = free_func != NULL_func; bool null3 = free_func != NULL_func;
bool null4 = member_func != NULL_func; bool null4 = member_func != NULL_func;
#ifdef LOKI_DISABLE_TYPELIST_MACROS #ifdef LOKI_DISABLE_TYPELIST_MACROS
bool bindFunctorCompare = bindFunctor==bindFunctor2;
bool chainFunctorCompare = chainFunctor==chainFunctor2; bool bindFunctorCompare = bindFunctor==bindFunctor2;
bool chainFunctorCompare = chainFunctor==chainFunctor2;
#endif #endif
bool compare = functionCompare && bool compare = functionCompare &&
functorCompare && functorCompare &&
classFunctorCompare && classFunctorCompare &&
functorCopyCompare && functorCopyCompare &&
mem_free && mem_free &&
free_mem && free_mem &&
null0 && null0 &&
null1 && null1 &&
null2 && null2 &&
null3 && null3 &&
null4 null4
#ifndef LOKI_DISABLE_TYPELIST_MACROS #ifndef LOKI_DISABLE_TYPELIST_MACROS
; ;
#else #else
&& bindFunctorCompare
&& chainFunctorCompare; && bindFunctorCompare
&& chainFunctorCompare;
#endif #endif
#else #else
bool compare=true;
bool compare=true;
#endif //LOKI_FUNCTORS_ARE_COMPARABLE #endif //LOKI_FUNCTORS_ARE_COMPARABLE
#ifdef LOKI_DISABLE_TYPELIST_MACROS #ifdef LOKI_DISABLE_TYPELIST_MACROS
testResult=false;
bindFunctor();
bool bindFunctorResult=testResult;
testResult=false; testResult=false;
chainFunctor(); bindFunctor();
bool chainFunctorResult=testResult; bool bindFunctorResult=testResult;
r=functionResult && functorResult && classFunctorResult && functorCopyResult && bindFunctorResult && testResult=false;
chainFunctorResult && compare; chainFunctor();
#else bool chainFunctorResult=testResult;
//TODO!
r=functionResult && functorResult && classFunctorResult && functorCopyResult && compare;
#endif
testAssert("Functor",r,result);
std::cout << '\n'; r=functionResult && functorResult && classFunctorResult && functorCopyResult && bindFunctorResult &&
chainFunctorResult && compare;
#else
//TODO!
r=functionResult && functorResult && classFunctorResult && functorCopyResult && compare;
#endif
testAssert("Functor",r,result);
std::cout << '\n';
} }
private: private:
static bool testResult; static bool testResult;
static void testFunction(bool &result) static void testFunction(bool &result)
{ {
result=true; result=true;
} }
class TestFunctor class TestFunctor
{ {
public: public:
void operator()(bool &result) void operator()(bool &result)
{ {
result=true; result=true;
} }
bool operator==(const TestFunctor& rhs) const bool operator==(const TestFunctor& rhs) const
{ {
const TestFunctor* p = &rhs; const TestFunctor* p = &rhs;
return this==p; return this==p;
} }
}; };
class TestClass class TestClass
{ {
public: public:
void member(bool &result) void member(bool &result)
{ {
result=true; result=true;
} }
}; };
} functorTest; }
functorTest;
bool FunctorTest::testResult; bool FunctorTest::testResult;