summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/tr1/8_c_compatibility/complex
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/tr1/8_c_compatibility/complex')
-rw-r--r--libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/50880.cc51
-rw-r--r--libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/51083.cc54
-rw-r--r--libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/functions.cc48
-rw-r--r--libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_float.cc102
-rw-r--r--libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc98
5 files changed, 353 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/50880.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/50880.cc
new file mode 100644
index 000000000..eaa2f3d81
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/50880.cc
@@ -0,0 +1,51 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, or (at your option)
+// any later version.
+//
+// This library 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 library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <tr1/complex>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ void test01_do()
+ {
+ bool test __attribute__((unused)) = true;
+
+ const std::complex<T> ca(T(-2), T(2));
+ const std::complex<T> cb(T(-2), T(0));
+ const std::complex<T> cc(T(-2), T(-2));
+
+ std::complex<T> cra = std::tr1::acosh(ca);
+ std::complex<T> crb = std::tr1::acosh(cb);
+ std::complex<T> crc = std::tr1::acosh(cc);
+
+ VERIFY( cra.real() > T(0) );
+ VERIFY( crb.real() > T(0) );
+ VERIFY( crc.real() > T(0) );
+ }
+
+// libstdc++/50880
+void test01()
+{
+ test01_do<float>();
+ test01_do<double>();
+ test01_do<long double>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/51083.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/51083.cc
new file mode 100644
index 000000000..f41914ee9
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/51083.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+//
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, or (at your option)
+// any later version.
+//
+// This library 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 library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <tr1/complex>
+
+namespace a
+{
+ template<typename> class Mat { };
+
+ template<typename T> struct Mat2 : Mat<T> { };
+
+ template<typename T> int arg(Mat<T>) { return 1; }
+ template<typename T> int conj(Mat<T>) { return 1; }
+ template<typename T> int imag(Mat<T>) { return 1; }
+ template<typename T> int norm(Mat<T>) { return 1; }
+ template<typename T> int proj(Mat<T>) { return 1; }
+ template<typename T> int real(Mat<T>) { return 1; }
+
+ template<typename T, typename U> int pow(Mat<T>, U) { return 1; }
+ template<typename T, typename U> int pow(T, Mat<U>) { return 1; }
+}
+
+int main()
+{
+ int __attribute__((unused)) i;
+
+ using namespace std::tr1;
+
+ a::Mat2< std::complex<double> > c;
+ i = arg(c);
+ i = conj(c);
+ i = imag(c);
+ i = norm(c);
+ i = proj(c);
+ i = real(c);
+ i = pow(std::complex<float>(), c);
+ i = pow(c, std::complex<float>());
+}
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/functions.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/functions.cc
new file mode 100644
index 000000000..3560d4fd4
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/functions.cc
@@ -0,0 +1,48 @@
+// { dg-do compile }
+
+// 2006-01-10 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, or (at your option)
+// any later version.
+//
+// This library 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 library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 8.1 Additions to header <complex>
+
+#include <tr1/complex>
+
+template<typename T>
+ void test01_do()
+ {
+ typedef std::complex<T> cmplx_type;
+
+ cmplx_type ans;
+
+ ans = std::tr1::acos(cmplx_type(1.0, 1.0));
+ ans = std::tr1::asin(cmplx_type(1.0, 1.0));
+ ans = std::tr1::atan(cmplx_type(1.0, 1.0));
+
+ ans = std::tr1::acosh(cmplx_type(1.0, 1.0));
+ ans = std::tr1::asinh(cmplx_type(1.0, 1.0));
+ ans = std::tr1::atanh(cmplx_type(1.0, 1.0));
+ ans = std::tr1::fabs(cmplx_type(1.0, 1.0));
+ }
+
+void test01()
+{
+ test01_do<float>();
+ test01_do<double>();
+ test01_do<long double>();
+}
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_float.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_float.cc
new file mode 100644
index 000000000..1e12cdba2
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_float.cc
@@ -0,0 +1,102 @@
+// { dg-do compile }
+
+// 2006-01-12 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, or (at your option)
+// any later version.
+//
+// This library 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 library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 8.1 Additions to header <complex>
+
+#include <tr1/complex>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ using __gnu_test::check_ret_type;
+
+ typedef std::complex<float> cmplx_f_type;
+ typedef std::complex<double> cmplx_d_type;
+ typedef std::complex<long double> cmplx_ld_type;
+
+ const float f1 = 1.0f;
+ const double d1 = 1.0;
+ const long double ld1 = 1.0l;
+
+ const cmplx_f_type c_f1(f1, f1);
+ const cmplx_d_type c_d1(d1, d1);
+ const cmplx_ld_type c_ld1(ld1, ld1);
+
+ check_ret_type<float>(std::tr1::arg(f1));
+ check_ret_type<double>(std::tr1::arg(d1));
+ check_ret_type<long double>(std::tr1::arg(ld1));
+
+ check_ret_type<cmplx_f_type>(std::tr1::conj(f1));
+ check_ret_type<cmplx_d_type>(std::tr1::conj(d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::conj(ld1));
+
+ check_ret_type<float>(std::tr1::imag(f1));
+ check_ret_type<double>(std::tr1::imag(d1));
+ check_ret_type<long double>(std::tr1::imag(ld1));
+
+ check_ret_type<float>(std::tr1::norm(f1));
+ check_ret_type<double>(std::tr1::norm(d1));
+ check_ret_type<long double>(std::tr1::norm(ld1));
+
+ check_ret_type<cmplx_f_type>(std::tr1::polar(f1, f1));
+ check_ret_type<cmplx_d_type>(std::tr1::polar(d1, f1));
+ check_ret_type<cmplx_d_type>(std::tr1::polar(f1, d1));
+ check_ret_type<cmplx_d_type>(std::tr1::polar(d1, d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::polar(ld1, d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::polar(d1, ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::polar(ld1, f1));
+ check_ret_type<cmplx_ld_type>(std::tr1::polar(f1, ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::polar(ld1, ld1));
+
+ check_ret_type<cmplx_f_type>(std::tr1::pow(c_f1, f1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(c_d1, f1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(c_f1, d1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(c_d1, d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_ld1, d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_d1, ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_ld1, f1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_f1, ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_ld1, ld1));
+
+ check_ret_type<cmplx_f_type>(std::tr1::pow(f1, c_f1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(d1, c_f1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(f1, c_d1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(d1, c_d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(ld1, c_d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(d1, c_ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(ld1, c_f1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(f1, c_ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(ld1, c_ld1));
+
+ check_ret_type<cmplx_f_type>(std::tr1::pow(c_f1, c_f1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(c_d1, c_f1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(c_f1, c_d1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(c_d1, c_d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_ld1, c_d1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_d1, c_ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_ld1, c_f1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_f1, c_ld1));
+ check_ret_type<cmplx_ld_type>(std::tr1::pow(c_ld1, c_ld1));
+
+ check_ret_type<float>(std::tr1::real(f1));
+ check_ret_type<double>(std::tr1::real(d1));
+ check_ret_type<long double>(std::tr1::real(ld1));
+}
diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc
new file mode 100644
index 000000000..a8a9bfba3
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc
@@ -0,0 +1,98 @@
+// 2006-01-12 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, or (at your option)
+// any later version.
+//
+// This library 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 library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 8.1 Additions to header <complex>
+
+#include <tr1/complex>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::check_ret_type;
+
+ typedef std::complex<float> cmplx_f_type;
+ typedef std::complex<double> cmplx_d_type;
+
+ const int i1 = 1;
+ const unsigned u1 = 1;
+ const long l1 = 1;
+ const double f1 = 1.0f;
+ const double d1 = 1.0;
+
+ check_ret_type<double>(std::tr1::arg(i1));
+ VERIFY( std::tr1::arg(i1) == std::tr1::arg(double(i1)) );
+ VERIFY( std::tr1::arg(i1) == std::tr1::arg(cmplx_d_type(double(i1))) );
+
+ check_ret_type<cmplx_d_type>(std::tr1::conj(i1));
+ VERIFY( std::tr1::conj(i1) == std::tr1::conj(double(i1)) );
+ VERIFY( std::tr1::conj(i1) == std::tr1::conj(cmplx_d_type(double(i1))) );
+
+ check_ret_type<double>(std::tr1::imag(i1));
+ VERIFY( std::tr1::imag(i1) == std::tr1::imag(double(i1)) );
+ VERIFY( std::tr1::imag(i1) == std::tr1::imag(cmplx_d_type(double(i1))) );
+
+ check_ret_type<double>(std::tr1::norm(i1));
+ VERIFY( std::tr1::norm(i1) == std::tr1::norm(double(i1)) );
+ // std::norm<const complex<>&) is mathematically equivalent to just
+ // this for a real, but the general algorithm goes through std::abs
+ // and a multiplication.
+ VERIFY( std::tr1::norm(i1) == double(i1) * double(i1) );
+
+ // NB: The existing std::polar wins and a cmplx_i_type is returned.
+ // check_ret_type<cmplx_d_type>(std::tr1::polar(i1, i1));
+ // VERIFY( std::tr1::polar(i1, i1)
+ // == std::tr1::polar(double(i1), double(i1)) );
+ typedef std::complex<int> cmplx_i_type;
+ check_ret_type<cmplx_i_type>(std::tr1::polar(i1, i1));
+
+ check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), i1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), u1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_f_type(f1, f1), l1));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(cmplx_d_type(d1, d1), i1));
+
+ VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), i1)
+ == std::tr1::pow(cmplx_d_type(d1, d1), double(i1)) );
+ VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), u1)
+ == std::tr1::pow(cmplx_d_type(d1, d1), double(u1)) );
+ VERIFY( std::tr1::pow(cmplx_d_type(d1, d1), l1)
+ == std::tr1::pow(cmplx_d_type(d1, d1), double(l1)) );
+
+ check_ret_type<cmplx_d_type>(std::tr1::pow(i1, cmplx_f_type(f1, f1)));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(u1, cmplx_f_type(f1, f1)));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(l1, cmplx_f_type(f1, f1)));
+ check_ret_type<cmplx_d_type>(std::tr1::pow(i1, cmplx_d_type(d1, d1)));
+ VERIFY( std::tr1::pow(i1, cmplx_d_type(d1, d1))
+ == std::tr1::pow(double(i1), cmplx_d_type(d1, d1)) );
+ VERIFY( std::tr1::pow(u1, cmplx_d_type(d1, d1))
+ == std::tr1::pow(double(u1), cmplx_d_type(d1, d1)) );
+ VERIFY( std::tr1::pow(l1, cmplx_d_type(d1, d1))
+ == std::tr1::pow(double(l1), cmplx_d_type(d1, d1)) );
+
+ check_ret_type<double>(std::tr1::real(i1));
+ VERIFY( std::tr1::real(i1) == std::tr1::real(double(i1)) );
+ VERIFY( std::tr1::real(i1) == std::tr1::real(cmplx_d_type(double(i1))) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}