From 6b4b0a58ca01d426f8c567ce76bb6d73a49f1e84 Mon Sep 17 00:00:00 2001 From: xscript Date: Fri, 29 Apr 2011 02:32:56 +0200 Subject: [PATCH] Move tests in cedet/semantic --- .../cedet/semantic/tests/testpolymorph.cpp | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 test/manual/cedet/cedet/semantic/tests/testpolymorph.cpp diff --git a/test/manual/cedet/cedet/semantic/tests/testpolymorph.cpp b/test/manual/cedet/cedet/semantic/tests/testpolymorph.cpp new file mode 100644 index 00000000000..ddf67d05827 --- /dev/null +++ b/test/manual/cedet/cedet/semantic/tests/testpolymorph.cpp @@ -0,0 +1,131 @@ +/** testpolymorph.cpp --- A sequence of polymorphism examples. + * + * Copyright (C) 2009 Eric M. Ludlam + * + * Author: Eric M. Ludlam + * X-RCS: $Id: testpolymorph.cpp,v 1.2 2009-09-02 13:55:46 davenar Exp $ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +// Test 1 - Functions w/ prototypes +namespace proto { + + int pt_func1(int arg1); + int pt_func1(int arg1) { + return 0; + } + +} + +// Test 2 - Functions w/ different arg lists. +namespace fcn_poly { + + int pm_func(void) { + return 0; + } + int pm_func(int a) { + return a; + } + int pm_func(char a) { + return int(a); + } + int pm_func(double a) { + return int(floor(a)); + } + +} + +// Test 3 - Methods w/ differet arg lists. +class meth_poly { +public: + int pm_meth(void) { + return 0; + } + int pm_meth(int a) { + return a; + } + int pm_meth(char a) { + return int(a); + } + int pm_meth(double a) { + return int(floor(a)); + } + +}; + +// Test 4 - Templates w/ partial specifiers. +namespace template_partial_spec { + template class test + { + public: + void doSomething(T t) { }; + }; + + template class test + { + public: + void doSomething(T* t) { }; + }; +} + +// Test 5 - Templates w/ full specicialization which may or may not share +// common functions. +namespace template_full_spec { + template class test + { + public: + void doSomething(T t) { }; + void doSomethingElse(T t) { }; + }; + + template <> class test + { + public: + void doSomethingElse(int t) { }; + void doSomethingCompletelyDifferent(int t) { }; + }; +} + +// Test 6 - Dto., but for templates with multiple parameters. +namespace template_multiple_spec { + template class test + { + public: + void doSomething(T1 t) { }; + void doSomethingElse(T2 t) { }; + }; + + template class test + { + public: + void doSomething(int t) { }; + void doSomethingElse(T2 t) { }; + }; + + template <> class test + { + public: + void doSomething(float t) { }; + void doSomethingElse(int t) { }; + void doNothing(void) { }; + }; +} + + +// End of polymorphism test file. -- 2.39.2