From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- .../testsuite/26_numerics/complex/13450.cc | 82 ++++++++++++ .../testsuite/26_numerics/complex/50880.cc | 53 ++++++++ .../testsuite/26_numerics/complex/51083.cc | 54 ++++++++ .../testsuite/26_numerics/complex/buggy_complex.cc | 35 ++++++ .../complex/comparison_operators/constexpr.cc | 39 ++++++ .../testsuite/26_numerics/complex/cons/48760.cc | 58 +++++++++ .../26_numerics/complex/cons/constexpr.cc | 37 ++++++ .../26_numerics/complex/cons/constexpr_primary.cc | 67 ++++++++++ .../testsuite/26_numerics/complex/dr387_2.cc | 30 +++++ .../testsuite/26_numerics/complex/dr781_dr1137.cc | 70 +++++++++++ .../testsuite/26_numerics/complex/dr844.cc | 51 ++++++++ .../complex/inserters_extractors/char/1.cc | 138 +++++++++++++++++++++ .../complex/inserters_extractors/wchar_t/1.cc | 136 ++++++++++++++++++++ libstdc++-v3/testsuite/26_numerics/complex/pow.cc | 16 +++ .../complex/requirements/constexpr_functions.cc | 57 +++++++++ .../26_numerics/complex/value_operations/1.cc | 65 ++++++++++ .../complex/value_operations/constexpr.cc | 57 +++++++++ .../26_numerics/complex/value_operations/dr387.cc | 51 ++++++++ 18 files changed, 1096 insertions(+) create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/13450.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/50880.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/51083.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/dr844.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/pow.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc (limited to 'libstdc++-v3/testsuite/26_numerics/complex') diff --git a/libstdc++-v3/testsuite/26_numerics/complex/13450.cc b/libstdc++-v3/testsuite/26_numerics/complex/13450.cc new file mode 100644 index 000000000..c34648e20 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/13450.cc @@ -0,0 +1,82 @@ +// { dg-do run { xfail broken_cplxf_arg } } + +// Copyright (C) 2004, 2009 Free Software Foundation +// +// 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 +// . + +// 26.2.8 complex transcendentals + +#include +#include +#include + +template + void test01_do(T a, T b) + { + using namespace std; + bool test __attribute__((unused)) = true; + typedef complex cplx; + + T eps = numeric_limits::epsilon() * 100; + + cplx ref = pow(cplx(a, T()), cplx(b, T())); + cplx res1 = pow(a, cplx(b, T())); + cplx res2 = pow(cplx(a, T()), b); + + VERIFY( abs(ref - res1) < eps ); + VERIFY( abs(ref - res2) < eps ); + VERIFY( abs(res1 - res2) < eps ); + } + +// libstdc++/13450 +void test01() +{ + float f1 = -1.0f; + float f2 = 0.5f; + test01_do(f1, f2); + + f1 = -3.2f; + f2 = 1.4f; + test01_do(f1, f2); + + double d1 = -1.0; + double d2 = 0.5; + test01_do(d1, d2); + + d1 = -3.2; + d2 = 1.4; + test01_do(d1, d2); + +#if __LDBL_MANT_DIG__ != 106 + /* For IBM long double, epsilon is too small (since 1.0 plus any + double is representable) to be able to expect results within + epsilon * 100 (which may be much less than 1ulp for a particular + long double value). */ + long double ld1 = -1.0l; + long double ld2 = 0.5l; + test01_do(ld1, ld2); + + ld1 = -3.2l; + ld2 = 1.4l; + test01_do(ld1, ld2); +#endif +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/50880.cc b/libstdc++-v3/testsuite/26_numerics/complex/50880.cc new file mode 100644 index 000000000..2b70a99dd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/50880.cc @@ -0,0 +1,53 @@ +// { 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 +// . + +#include +#include + +template + void test01_do() + { + bool test __attribute__((unused)) = true; + + const std::complex ca(T(-2), T(2)); + const std::complex cb(T(-2), T(0)); + const std::complex cc(T(-2), T(-2)); + + std::complex cra = std::acosh(ca); + std::complex crb = std::acosh(cb); + std::complex crc = std::acosh(cc); + + VERIFY( cra.real() > T(0) ); + VERIFY( crb.real() > T(0) ); + VERIFY( crc.real() > T(0) ); + } + +// libstdc++/50880 +void test01() +{ + test01_do(); + test01_do(); + test01_do(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/51083.cc b/libstdc++-v3/testsuite/26_numerics/complex/51083.cc new file mode 100644 index 000000000..54e781ba1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/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 +// . + +#include + +namespace a +{ + template class Mat { }; + + template struct Mat2 : Mat { }; + + template int arg(Mat) { return 1; } + template int conj(Mat) { return 1; } + template int imag(Mat) { return 1; } + template int norm(Mat) { return 1; } + template int proj(Mat) { return 1; } + template int real(Mat) { return 1; } + + template int pow(Mat, U) { return 1; } + template int pow(T, Mat) { return 1; } +} + +int main() +{ + int __attribute__((unused)) i; + + using namespace std; + + a::Mat2< std::complex > c; + i = arg(c); + i = conj(c); + i = imag(c); + i = norm(c); + i = proj(c); + i = real(c); + i = pow(std::complex(), c); + i = pow(c, std::complex()); +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc b/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc new file mode 100644 index 000000000..a6cbc9991 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc @@ -0,0 +1,35 @@ +// 2000-02-09 +// Gabriel Dos Reis + +// Copyright (C) 1999, 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 +// . + + +// Test buggy builtin GNU __complex__ support. This used to cause +// an ICE on some 64-bits plateforms. +// Origin: petter@matfys.lth.se + +#include + +int main() +{ + std::complex a(9), b(0, 8), c; + + c = a * b; + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc new file mode 100644 index 000000000..85c3ab7b4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/comparison_operators/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_comparison_eq_ne test; + test.operator()>(); + test.operator(), float>(); + test.operator()>(); + + test.operator()>(); + test.operator(), double>(); + test.operator()>(); + + test.operator()>(); + test.operator(), long double>(); + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc new file mode 100644 index 000000000..0027a34e4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/48760.cc @@ -0,0 +1,58 @@ +// { dg-require-c-std "" } + +// 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 +// . + +#include +#include +#include + +template + void do_test01() + { + bool test __attribute__((unused)) = true; + + if (std::numeric_limits::has_quiet_NaN) + { + std::complex c1(T(0), std::numeric_limits::quiet_NaN()); + VERIFY( c1.real() == T(0) ); + VERIFY( std::isnan(c1.imag()) ); + + std::complex c2(std::numeric_limits::quiet_NaN(), T(0)); + VERIFY( std::isnan(c2.real()) ); + VERIFY( c2.imag() == T(0) ); + + std::complex c3(std::numeric_limits::quiet_NaN(), + std::numeric_limits::quiet_NaN()); + VERIFY( std::isnan(c3.real()) ); + VERIFY( std::isnan(c3.imag()) ); + } + } + +// libstdc++/48760 +void test01() +{ + do_test01(); + do_test01(); + do_test01(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc new file mode 100644 index 000000000..13d3c8168 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + test1.operator()>(); + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator(), float>(); + test2.operator(), double>(); + test2.operator(), long double>(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc new file mode 100644 index 000000000..77e01bcff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/cons/constexpr_primary.cc @@ -0,0 +1,67 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +#include + +// User defined type, so that the primary std::complex template is used. +namespace numext +{ + struct ldld_base + { + long double one; + long double two; + }; + + struct ldld_lit : public ldld_base + { }; + + struct ldld_nonlit : public ldld_base + { + ~ldld_nonlit() { } + }; + + bool + operator<(const ldld_base __a, const ldld_base __b) + { return __a.one < __b.one && __a.two < __b.two; } + + bool + operator==(const ldld_base __a, const ldld_base __b) + { return __a.one == __b.one && __a.two == __b.two; } + + ldld_base + operator+=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one + __b.one, __a.two + __b.two}); } + + ldld_base + operator-=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one - __b.one, __a.two - __b.two}); } + + ldld_base + operator*=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one * __b.one, __a.two * __b.two}); } + + ldld_base + operator/=(const ldld_base __a, const ldld_base __b) + { return ldld_base({ __a.one / __b.one, __a.two / __b.two}); } + +} + +constexpr std::complex lit; // ok +// constexpr std::complex nonlit; // error diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc new file mode 100644 index 000000000..06e0380cc --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr387_2.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 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 +// . + +#include + +// DR 387. std::complex over-encapsulated. +// http://gcc.gnu.org/ml/gcc/2009-03/msg00264.html +typedef std::complex C; + +C f1(C& c) { return c+1.0; } +C f2(C& c) { return c-1.0; } +C f3(C& c) { return 1.0+c; } +C f4(C& c) { return 1.0-c; } diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc new file mode 100644 index 000000000..145a4b044 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-22 Paolo Carlini +// +// Copyright (C) 2008, 2009, 2010 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 +// . + +#include +#include +#include + +// DR 781. std::complex should add missing C99 functions. +// DR 1137. Return type of conj and proj. +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + typedef std::complex cmplx_f_type; + typedef std::complex cmplx_d_type; + typedef std::complex cmplx_ld_type; + + const int i1 = 1; + 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(std::proj(c_f1)); + check_ret_type(std::proj(c_d1)); + check_ret_type(std::proj(c_ld1)); + + check_ret_type(std::proj(f1)); + check_ret_type(std::proj(d1)); + check_ret_type(std::proj(i1)); + VERIFY( std::proj(i1) == std::proj(double(i1)) ); + check_ret_type(std::proj(ld1)); + + check_ret_type(std::conj(c_f1)); + check_ret_type(std::conj(c_d1)); + check_ret_type(std::conj(c_ld1)); + + check_ret_type(std::conj(f1)); + check_ret_type(std::conj(d1)); + check_ret_type(std::conj(i1)); + VERIFY( std::conj(i1) == std::conj(double(i1)) ); + check_ret_type(std::conj(ld1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc new file mode 100644 index 000000000..909ec27a9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/dr844.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// 2008-06-12 Paolo Carlini +// +// Copyright (C) 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 +// . + +#include +#include +#include + +// DR 844. complex pow return type is ambiguous. +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + typedef std::complex cmplx_f_type; + typedef std::complex cmplx_d_type; + typedef std::complex cmplx_ld_type; + + const int i1 = 1; + const float f1 = 1.0f; + const double d1 = 1.0; + const long double ld1 = 1.0l; + + check_ret_type(std::pow(cmplx_f_type(f1, f1), i1)); + VERIFY( std::pow(cmplx_f_type(f1, f1), i1) + == std::pow(cmplx_d_type(f1, f1), double(i1)) ); + check_ret_type(std::pow(cmplx_d_type(d1, d1), i1)); + check_ret_type(std::pow(cmplx_ld_type(ld1, ld1), i1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc new file mode 100644 index 000000000..b7e65594c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/char/1.cc @@ -0,0 +1,138 @@ +// 2000-02-10 +// Petter Urkedal + +// Copyright (C) 2000, 2003, 2009 Free Software Foundation +// +// 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 +// . + + +#include +#include +#include +#include +#include +#include + +template +inline bool flteq(R x, R y) +{ + if (x == R(0)) return y == R(0); + else return std::fabs(x-y) < 1e-6*std::fabs(x); +} + +template +int +test_good(std::string str, R x, R y) +{ + bool test __attribute__((unused)) = true; + std::complex z; + char ch; + std::istringstream iss(str); + iss >> z >> ch; + VERIFY( iss.good() ); + VERIFY( flteq(z.real(), x) ); + VERIFY( flteq(z.imag(), y) ); + VERIFY( ch == '#' ); + return 0; +} + +template +int +test_fail(std::string str) +{ + bool test __attribute__((unused)) = true; + std::complex z; + std::istringstream iss(str); + iss >> z; + VERIFY( iss.fail() && !iss.bad() ); + return 0; +} + +template +int +testall() +{ + test_good("(-1.1,3.7)#", -1.1, 3.7); + test_good("( .7e6 , \n-3.1)#", .7e6, -3.1); + test_good("(\t0,-1)#", 0.0, -1.0); + test_good("(-3.14)#", -3.14, 0.0); + test_good("-.1#", -.1, 0.0); + test_good(" ( -2.7e3 )#", -2.7e3, 0.0); + test_good(" -.1#", -.1, 0.0); + test_fail("(a,1)"); + test_fail("(,1)"); + test_fail("(1,a)"); + test_fail("(1, )"); + test_fail("|1,1)"); + test_fail("(1|1)"); + test_fail("(1,1|"); + return 0; +} + +// libstdc++/2970 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + complex cf01(-1.1, -333.2); + stringstream ss; + ss << cf01; + string str = ss.str(); + VERIFY( str == "(-1.1,-333.2)" ); +} + +// libstdc++/2985 +struct gnu_char_traits : public std::char_traits +{ }; + +typedef std::basic_ostringstream gnu_sstream; +template class std::basic_string >; + +void test02() +{ + bool test __attribute__((unused)) = true; + + // Construct locale with specialized facets. + typedef gnu_sstream::__num_put_type numput_type; + typedef gnu_sstream::__num_get_type numget_type; + std::locale loc_c = std::locale::classic(); + std::locale loc_1(loc_c, new numput_type); + std::locale loc_2(loc_1, new numget_type); + VERIFY( std::has_facet(loc_2) ); + VERIFY( std::has_facet(loc_2) ); + + gnu_sstream sstr; + sstr.imbue(loc_2); + + + std::complex x(3, 4); + sstr << x; + VERIFY( sstr.str() == "(3,4)" ); +} + +int +main() +{ + testall(); + testall(); + testall(); + + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc new file mode 100644 index 000000000..8b23aec19 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/inserters_extractors/wchar_t/1.cc @@ -0,0 +1,136 @@ +// Copyright (C) 2007, 2009 Free Software Foundation +// +// 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 +// . + + +#include +#include +#include +#include +#include +#include + +template +inline bool flteq(R x, R y) +{ + if (x == R(0)) return y == R(0); + else return std::fabs(x-y) < 1e-6*std::fabs(x); +} + +template +int +test_good(std::wstring str, R x, R y) +{ + bool test __attribute__((unused)) = true; + std::complex z; + wchar_t ch; + std::wistringstream iss(str); + iss >> z >> ch; + VERIFY( iss.good() ); + VERIFY( flteq(z.real(), x) ); + VERIFY( flteq(z.imag(), y) ); + VERIFY( ch == L'#' ); + return 0; +} + +template +int +test_fail(std::wstring str) +{ + bool test __attribute__((unused)) = true; + std::complex z; + std::wistringstream iss(str); + iss >> z; + VERIFY( iss.fail() && !iss.bad() ); + return 0; +} + +template +int +testall() +{ + test_good(L"(-1.1,3.7)#", -1.1, 3.7); + test_good(L"( .7e6 , \n-3.1)#", .7e6, -3.1); + test_good(L"(\t0,-1)#", 0.0, -1.0); + test_good(L"(-3.14)#", -3.14, 0.0); + test_good(L"-.1#", -.1, 0.0); + test_good(L" ( -2.7e3 )#", -2.7e3, 0.0); + test_good(L" -.1#", -.1, 0.0); + test_fail(L"(a,1)"); + test_fail(L"(,1)"); + test_fail(L"(1,a)"); + test_fail(L"(1, )"); + test_fail(L"|1,1)"); + test_fail(L"(1|1)"); + test_fail(L"(1,1|"); + return 0; +} + +// libstdc++/2970 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + complex cf01(-1.1, -333.2); + wstringstream ss; + ss << cf01; + wstring str = ss.str(); + VERIFY( str == L"(-1.1,-333.2)" ); +} + +// libstdc++/2985 +struct gnu_char_traits : public std::char_traits +{ }; + +typedef std::basic_ostringstream gnu_sstream; +template class std::basic_string >; + +void test02() +{ + bool test __attribute__((unused)) = true; + + // Construct locale with specialized facets. + typedef gnu_sstream::__num_put_type numput_type; + typedef gnu_sstream::__num_get_type numget_type; + std::locale loc_c = std::locale::classic(); + std::locale loc_1(loc_c, new numput_type); + std::locale loc_2(loc_1, new numget_type); + VERIFY( std::has_facet(loc_2) ); + VERIFY( std::has_facet(loc_2) ); + + gnu_sstream sstr; + sstr.imbue(loc_2); + + + std::complex x(3, 4); + sstr << x; + VERIFY( sstr.str() == L"(3,4)" ); +} + +int +main() +{ + testall(); + testall(); + testall(); + + test01(); + test02(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/pow.cc b/libstdc++-v3/testsuite/26_numerics/complex/pow.cc new file mode 100644 index 000000000..a43e3c674 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/pow.cc @@ -0,0 +1,16 @@ +// { dg-do run { xfail broken_cplxf_arg } } +// PR libstdc++/10689 +// Origin: Daniel.Levine@jhuaph.edu +// { dg-add-options ieee } + +#include +#include + +int main() +{ + std::complex z; + + VERIFY( pow(z, 1.0/3.0) == 0.0 ); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc new file mode 100644 index 000000000..eae5ee7e8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/requirements/constexpr_functions.cc @@ -0,0 +1,57 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + typedef typename _Ttesttype::_ComplexT _ComplexT; + const _ComplexT cc = { 1.1 }; + constexpr _Ttesttype a(cc); + constexpr auto v1 __attribute__((unused)) = a.real(); + constexpr auto v2 __attribute__((unused)) = a.imag(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()>(); + test.operator()>(); + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc new file mode 100644 index 000000000..dc05a2b19 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/1.cc @@ -0,0 +1,65 @@ +// { dg-do run { xfail broken_cplxf_arg } } +// { dg-options "-O0" } +// 2000-11-20 +// Benjamin Kosnik bkoz@redhat.com + +// Copyright (C) 2000, 2003, 2004, 2009, 2010 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 +// . + +#include +#include + +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef complex complex_type; + const double cd1 = -11.451; + const double cd2 = -442.1533; + + complex_type a(cd1, cd2); + double d; + d = a.real(); + VERIFY( d == cd1 ); + + d = a.imag(); + VERIFY( d == cd2 ); + + complex_type c(cd1, cd2); + double d6 = abs(c); + VERIFY( d6 >= 0 ); + + double d7 = arg(c); + double d8 = atan2(c.imag(), c.real()); + VERIFY( d7 == d8 ); + + double d9 = norm(c); + double d10 = d6 * d6; + VERIFY( d9 - d10 == 0 ); + + complex_type e __attribute__((unused)) = conj(c); + + complex_type f = polar(c.imag(), 0.0); + VERIFY( f.real() != 0 ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc new file mode 100644 index 000000000..29728a2b3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/constexpr.cc @@ -0,0 +1,57 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_functions + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + typedef typename _Ttesttype::_ComplexT _ComplexT; + const _ComplexT cc = { 1.1 }; + constexpr _Ttesttype a(cc); + constexpr auto v1 __attribute__((unused)) = real(a); + constexpr auto v2 __attribute__((unused)) = imag(a); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_functions test; + test.operator()>(); + test.operator()>(); + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc new file mode 100644 index 000000000..084a52c31 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/dr387.cc @@ -0,0 +1,51 @@ +// 2008-05-22 Paolo Carlini +// +// Copyright (C) 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 +// . + +#include +#include + +// DR 387. std::complex over-encapsulated. +template + void + do_test() + { + bool test __attribute__((unused)) = true; + + const T r = 1.0; + const T i = -1.0; + const T v = 0.0; + + std::complex z1(r, i); + z1.real(v); + VERIFY( z1.real() == v ); + VERIFY( z1.imag() == i ); + + std::complex z2(r, i); + z2.imag(v); + VERIFY( z2.real() == r ); + VERIFY( z2.imag() == v ); + } + +int main() +{ + do_test(); + do_test(); + do_test(); + return 0; +} -- cgit v1.2.3