From: Paolo Carlini Date: Tue, 22 Jun 2004 10:52:14 +0000 (+0000) Subject: complex_inserters_extractors.cc, [...]: Move to... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=482c0c5d0f514da98ecf74cac10dec078bd96a0c;p=gcc.git complex_inserters_extractors.cc, [...]: Move to... 2004-06-22 Paolo Carlini * testsuite/26_numerics/complex_inserters_extractors.cc, complex_value.cc, buggy_complex.cc: Move to... * testsuite/26_numerics/complex/: ... here. * testsuite/26_numerics/c99_classification_macros_c++.cc, c99_classification_macros_c.cc, c_math.cc, c_math_dynamic.cc, fabs_inline.cc: Move to... * testsuite/26_numerics/cmath/: ... here. * testsuite/26_numerics/binary_closure.cc, slice.cc, slice_array_assignment.cc, valarray.cc, valarray_const_bracket.cc, valarray_name_lookup.cc, valarray_operators.cc, valarray_subset_assignment.cc: Move to... * testsuite/26_numerics/valarray/: ... here (new dir). * testsuite/26_numerics/sum_diff.cc: Move to... * testsuite/26_numerics/numeric/: ... here (new dir). From-SVN: r83489 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7e0b5e7c1bf..96d8e595873 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2004-06-22 Paolo Carlini + + * testsuite/26_numerics/complex_inserters_extractors.cc, + complex_value.cc, buggy_complex.cc: Move to... + * testsuite/26_numerics/complex/: ... here. + * testsuite/26_numerics/c99_classification_macros_c++.cc, + c99_classification_macros_c.cc, c_math.cc, c_math_dynamic.cc, + fabs_inline.cc: Move to... + * testsuite/26_numerics/cmath/: ... here. + * testsuite/26_numerics/binary_closure.cc, slice.cc, + slice_array_assignment.cc, valarray.cc, valarray_const_bracket.cc, + valarray_name_lookup.cc, valarray_operators.cc, + valarray_subset_assignment.cc: Move to... + * testsuite/26_numerics/valarray/: ... here (new dir). + * testsuite/26_numerics/sum_diff.cc: Move to... + * testsuite/26_numerics/numeric/: ... here (new dir). + 2004-06-22 Paolo Carlini * include/std/std_istream.h (ignore(streamsize __n = 1, diff --git a/libstdc++-v3/testsuite/26_numerics/binary_closure.cc b/libstdc++-v3/testsuite/26_numerics/binary_closure.cc deleted file mode 100644 index 7dbcfbd5228..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/binary_closure.cc +++ /dev/null @@ -1,37 +0,0 @@ -// 19990805 gdr -// -// XXX: to impove later. -// Origin: Andreas Amann -// CXXFLAGS: -g - -#include -#include - - -int main() -{ - std::valarray a(10), b(10), c(10), d(10); - - a = 1.2; - b = 3.1; - - c = 4.0; - - d = ( 2.0 * b + a ); // works - std::cout << "d[4] = " << d[4] << std::endl; - - d = (a * 2.0 + b ); // works - std::cout << "d[4] = " << d[4] << std::endl; - - d = (a + b * 2.0 ); // segfaults! - std::cout << "d[4] = " << d[4] << std::endl; - d = (a + 2.0* b ); - - std::cout << "d[4] = " << d[4] << std::endl; - d = (a + 2.0* b ); - std::cout << "d[4] = " << d[4] << std::endl; - d = (a + 2.0* b ); - - std::cout << "d[4] = " << d[4] << std::endl; - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/buggy_complex.cc b/libstdc++-v3/testsuite/26_numerics/buggy_complex.cc deleted file mode 100644 index 37930fc5b0b..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/buggy_complex.cc +++ /dev/null @@ -1,36 +0,0 @@ -// 2000-02-09 -// Gabriel Dos Reis - -// Copyright (C) 1999 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - - -// 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/c99_classification_macros_c++.cc b/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc deleted file mode 100644 index 543f3d43fc9..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c++.cc +++ /dev/null @@ -1,91 +0,0 @@ -// 2001-04-06 gdr - -// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// { dg-do compile } - -#include - -void fpclassify() { } - -void isfinite() { } - -void isinf() { } - -void isnan() { } - -void isnormal() { } - -void signbit() { } - -void isgreater() { } - -void isgreaterequal() { } - -void isless() { } - -void islessequal() { } - -void islessgreater() { } - -void isunordered() { } - -#if _GLIBCXX_USE_C99 -template - void test_c99_classify() - { - bool test __attribute__((unused)) = true; - - typedef _Tp fp_type; - fp_type f1 = 1.0; - fp_type f2 = 3.0; - int res = 0; - - res = std::fpclassify(f1); - res = std::isfinite(f2); - res = std::isinf(f1); - res = std::isnan(f2); - res = std::isnormal(f1); - res = std::signbit(f2); - res = std::isgreater(f1, f2); - res = std::isgreaterequal(f1, f2); - res = std::isless(f1, f2); - res = std::islessequal(f1,f2); - res = std::islessgreater(f1, f2); - res = std::isunordered(f1, f2); - } -#endif - -int main() -{ -#if _GLIBCXX_USE_C99 - test_c99_classify(); - //test_c99_classify(); -#endif - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c.cc b/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c.cc deleted file mode 100644 index 15508a303fd..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/c99_classification_macros_c.cc +++ /dev/null @@ -1,58 +0,0 @@ -// 2001-04-06 gdr - -// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// { dg-do compile { xfail *-*-linux-gnu *-*-freebsd5* } } -// { dg-excess-errors "" { target *-*-linux-gnu *-*-freebsd5* } } - -#include - -void fpclassify() { } - -void isfinite() { } - -void isinf() { } - -void isnan() { } - -void isnormal() { } - -void signbit() { } - -void isgreater() { } - -void isgreaterequal() { } - -void isless() { } - -void islessequal() { } - -void islessgreater() { } - -void isunordered() { } - diff --git a/libstdc++-v3/testsuite/26_numerics/c_math.cc b/libstdc++-v3/testsuite/26_numerics/c_math.cc deleted file mode 100644 index 60cb5d05a01..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/c_math.cc +++ /dev/null @@ -1,71 +0,0 @@ -// 1999-06-05 -// Gabriel Dos Reis - -// Copyright (C) 2000, 1999 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -#include -#include - -// test compilation. -int -test01() -{ - float a = 1.f; - float b; - std::modf(a, &b); - return 0; -} - -// need more extravagant checks than this, of course, but this used to core... -int -test02() -{ - std::sin(static_cast(0)); - return 0; -} - -// as did this. -int -test03() -{ - double powtest __attribute__((unused)) = std::pow(2., 0); - return 0; -} - -// this used to abort. -int -test04() -{ - bool test __attribute__((unused)) = true; - float x[2] = {1, 2}; - float y = 3.4; - std::modf(y, &x[0]); - VERIFY(x[1] == 2); - return 0; -} - -int -main() -{ - test01(); - test02(); - test03(); - test04(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/c_math_dynamic.cc b/libstdc++-v3/testsuite/26_numerics/c_math_dynamic.cc deleted file mode 100644 index 86a6f930f72..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/c_math_dynamic.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Inspired by libstdc++/7680 & 26_numerics/c_math.cc, 2003-04-12 ljr - -// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// { dg-do link } -// { dg-options "-D_XOPEN_SOURCE" { target *-*-freebsd* } } - -#include - -int -test01() -{ - float a = 1.f; - float b; - std::modf(a, &b); - return 0; -} - -int -test02 () -{ - float a = 0.0f; - float b __attribute__((unused)) = std::acos(a); - return 0; -} - -int -main() -{ - test01(); - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/cmath/c99_classification_macros_c++.cc b/libstdc++-v3/testsuite/26_numerics/cmath/c99_classification_macros_c++.cc new file mode 100644 index 00000000000..543f3d43fc9 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cmath/c99_classification_macros_c++.cc @@ -0,0 +1,91 @@ +// 2001-04-06 gdr + +// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-do compile } + +#include + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + +#if _GLIBCXX_USE_C99 +template + void test_c99_classify() + { + bool test __attribute__((unused)) = true; + + typedef _Tp fp_type; + fp_type f1 = 1.0; + fp_type f2 = 3.0; + int res = 0; + + res = std::fpclassify(f1); + res = std::isfinite(f2); + res = std::isinf(f1); + res = std::isnan(f2); + res = std::isnormal(f1); + res = std::signbit(f2); + res = std::isgreater(f1, f2); + res = std::isgreaterequal(f1, f2); + res = std::isless(f1, f2); + res = std::islessequal(f1,f2); + res = std::islessgreater(f1, f2); + res = std::isunordered(f1, f2); + } +#endif + +int main() +{ +#if _GLIBCXX_USE_C99 + test_c99_classify(); + //test_c99_classify(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/cmath/c99_classification_macros_c.cc b/libstdc++-v3/testsuite/26_numerics/cmath/c99_classification_macros_c.cc new file mode 100644 index 00000000000..15508a303fd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cmath/c99_classification_macros_c.cc @@ -0,0 +1,58 @@ +// 2001-04-06 gdr + +// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-do compile { xfail *-*-linux-gnu *-*-freebsd5* } } +// { dg-excess-errors "" { target *-*-linux-gnu *-*-freebsd5* } } + +#include + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + diff --git a/libstdc++-v3/testsuite/26_numerics/cmath/c_math.cc b/libstdc++-v3/testsuite/26_numerics/cmath/c_math.cc new file mode 100644 index 00000000000..60cb5d05a01 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cmath/c_math.cc @@ -0,0 +1,71 @@ +// 1999-06-05 +// Gabriel Dos Reis + +// Copyright (C) 2000, 1999 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include +#include + +// test compilation. +int +test01() +{ + float a = 1.f; + float b; + std::modf(a, &b); + return 0; +} + +// need more extravagant checks than this, of course, but this used to core... +int +test02() +{ + std::sin(static_cast(0)); + return 0; +} + +// as did this. +int +test03() +{ + double powtest __attribute__((unused)) = std::pow(2., 0); + return 0; +} + +// this used to abort. +int +test04() +{ + bool test __attribute__((unused)) = true; + float x[2] = {1, 2}; + float y = 3.4; + std::modf(y, &x[0]); + VERIFY(x[1] == 2); + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/cmath/c_math_dynamic.cc b/libstdc++-v3/testsuite/26_numerics/cmath/c_math_dynamic.cc new file mode 100644 index 00000000000..86a6f930f72 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cmath/c_math_dynamic.cc @@ -0,0 +1,58 @@ +// Inspired by libstdc++/7680 & 26_numerics/c_math.cc, 2003-04-12 ljr + +// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-do link } +// { dg-options "-D_XOPEN_SOURCE" { target *-*-freebsd* } } + +#include + +int +test01() +{ + float a = 1.f; + float b; + std::modf(a, &b); + return 0; +} + +int +test02 () +{ + float a = 0.0f; + float b __attribute__((unused)) = std::acos(a); + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/cmath/fabs_inline.cc b/libstdc++-v3/testsuite/26_numerics/cmath/fabs_inline.cc new file mode 100644 index 00000000000..5dffb7d12c1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cmath/fabs_inline.cc @@ -0,0 +1,37 @@ +// Copyright (C) 1999, 2002 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// Test to see whether the host provides its own (inline) view of fabs. +// Origin: Kurt Garloff , 2001-05-24 +// dg-do link + +#include +#include + +typedef double (*realfn) (double); + +using std::fabs; + +int main () +{ + double a = fabs (-2.4); + realfn myfn = fabs; + double b = myfn (-2.5); + std::printf ("%f, %f, %p\n", a, b, myfn); + return 0; +} 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 00000000000..37930fc5b0b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/buggy_complex.cc @@ -0,0 +1,36 @@ +// 2000-02-09 +// Gabriel Dos Reis + +// Copyright (C) 1999 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + + +// 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/complex_inserters_extractors.cc b/libstdc++-v3/testsuite/26_numerics/complex/complex_inserters_extractors.cc new file mode 100644 index 00000000000..b7059f7e864 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/complex_inserters_extractors.cc @@ -0,0 +1,143 @@ +// 2000-02-10 +// Petter Urkedal + +// Copyright (C) 2000, 2003 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + + +#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/complex_value.cc b/libstdc++-v3/testsuite/26_numerics/complex/complex_value.cc new file mode 100644 index 00000000000..03f26284092 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/complex_value.cc @@ -0,0 +1,65 @@ +// { dg-options "-O0" } +// 2000-11-20 +// Benjamin Kosnik bkoz@redhat.com + +// Copyright (C) 2000, 2003, 2004 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#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 = 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_inserters_extractors.cc b/libstdc++-v3/testsuite/26_numerics/complex_inserters_extractors.cc deleted file mode 100644 index b7059f7e864..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/complex_inserters_extractors.cc +++ /dev/null @@ -1,143 +0,0 @@ -// 2000-02-10 -// Petter Urkedal - -// Copyright (C) 2000, 2003 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - - -#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_value.cc b/libstdc++-v3/testsuite/26_numerics/complex_value.cc deleted file mode 100644 index 03f26284092..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/complex_value.cc +++ /dev/null @@ -1,65 +0,0 @@ -// { dg-options "-O0" } -// 2000-11-20 -// Benjamin Kosnik bkoz@redhat.com - -// Copyright (C) 2000, 2003, 2004 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -#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 = 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/fabs_inline.cc b/libstdc++-v3/testsuite/26_numerics/fabs_inline.cc deleted file mode 100644 index 5dffb7d12c1..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/fabs_inline.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 1999, 2002 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// Test to see whether the host provides its own (inline) view of fabs. -// Origin: Kurt Garloff , 2001-05-24 -// dg-do link - -#include -#include - -typedef double (*realfn) (double); - -using std::fabs; - -int main () -{ - double a = fabs (-2.4); - realfn myfn = fabs; - double b = myfn (-2.5); - std::printf ("%f, %f, %p\n", a, b, myfn); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/numeric/sum_diff.cc b/libstdc++-v3/testsuite/26_numerics/numeric/sum_diff.cc new file mode 100644 index 00000000000..9a4cf68c1d5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numeric/sum_diff.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 26.4.3 [lib.partial.sum] +// 26.4.4 [lib.adjacent.difference] + +#include +#include +#include + +int A[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; +int B[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + int D[N]; + + std::adjacent_difference(A, A + N, D); + assert(std::equal(D, D + N, B)); + + std::partial_sum(D, D + N, D); + assert(std::equal(D, D + N, A)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/slice.cc b/libstdc++-v3/testsuite/26_numerics/slice.cc deleted file mode 100644 index a7278edfc90..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/slice.cc +++ /dev/null @@ -1,64 +0,0 @@ -// 20020717 gdr - -// Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// Test slice class invariants - -#include -#include -#include - -bool -construction(std::size_t start, std::size_t size, std::size_t stride) -{ - std::slice s(start, size, stride); - return s.start() == start && s.size() == size && s.stride() == stride; -} - -bool -copy(std::size_t start, std::size_t size, std::size_t stride) -{ - std::slice s(start, size, stride); - std::slice t = s; - return t.start() == start && t.size() == size && t.stride() == stride; -} - -bool -assignment(std::size_t start, std::size_t size, std::size_t stride) -{ - std::slice s(start, size, stride); - std::slice t; - t = s; - return t.start() == start && t.size() == size && t.stride() == stride; -} - - -int main() -{ - bool test __attribute__((unused)) = true; - std::srand(20020717); - using std::rand; - VERIFY(construction(rand(), rand(), rand())); - - VERIFY(copy(rand(), rand(), rand())); - - VERIFY(assignment(rand(), rand(), rand())); - - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/slice_array_assignment.cc b/libstdc++-v3/testsuite/26_numerics/slice_array_assignment.cc deleted file mode 100644 index 2d5af920735..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/slice_array_assignment.cc +++ /dev/null @@ -1,51 +0,0 @@ -// 20010613 gdr - -// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - - -// This is DR-253. Test for accessible assignment-operators. -#include -#include - -int main() -{ - bool test __attribute__((unused)) = true; - using std::valarray; - using std::slice; - valarray v(1, 10), w(2, 10); - - w[slice(0, 3, 3)] = v[slice(2, 3, 3)]; - - VERIFY(v[0] == 1 && w[0] == 1); - VERIFY(v[3] == 1 && w[3] == 1); - VERIFY(v[6] == 1 && w[6] == 1); - - std::slice_array t = v[slice(0, 10, 1)]; - - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/sum_diff.cc b/libstdc++-v3/testsuite/26_numerics/sum_diff.cc deleted file mode 100644 index 9a4cf68c1d5..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/sum_diff.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// 26.4.3 [lib.partial.sum] -// 26.4.4 [lib.adjacent.difference] - -#include -#include -#include - -int A[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; -int B[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19}; -const int N = sizeof(A) / sizeof(int); - -void -test01() -{ - int D[N]; - - std::adjacent_difference(A, A + N, D); - assert(std::equal(D, D + N, B)); - - std::partial_sum(D, D + N, D); - assert(std::equal(D, D + N, A)); -} - -int -main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray.cc b/libstdc++-v3/testsuite/26_numerics/valarray.cc deleted file mode 100644 index 37c9e0286e4..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/valarray.cc +++ /dev/null @@ -1,43 +0,0 @@ -// 19990404 gdr - -// Copyright (C) 1999, 2000 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#include - -int main() -{ - // 01: instantiation - std::valarray a(20); - - // 02: algo - using std::valarray; - valarray b, c; - double m __attribute__((unused)) = std::abs(b - c).max(); - - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc b/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc new file mode 100644 index 00000000000..7dbcfbd5228 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc @@ -0,0 +1,37 @@ +// 19990805 gdr +// +// XXX: to impove later. +// Origin: Andreas Amann +// CXXFLAGS: -g + +#include +#include + + +int main() +{ + std::valarray a(10), b(10), c(10), d(10); + + a = 1.2; + b = 3.1; + + c = 4.0; + + d = ( 2.0 * b + a ); // works + std::cout << "d[4] = " << d[4] << std::endl; + + d = (a * 2.0 + b ); // works + std::cout << "d[4] = " << d[4] << std::endl; + + d = (a + b * 2.0 ); // segfaults! + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + + std::cout << "d[4] = " << d[4] << std::endl; + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/slice.cc b/libstdc++-v3/testsuite/26_numerics/valarray/slice.cc new file mode 100644 index 00000000000..a7278edfc90 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/slice.cc @@ -0,0 +1,64 @@ +// 20020717 gdr + +// Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// Test slice class invariants + +#include +#include +#include + +bool +construction(std::size_t start, std::size_t size, std::size_t stride) +{ + std::slice s(start, size, stride); + return s.start() == start && s.size() == size && s.stride() == stride; +} + +bool +copy(std::size_t start, std::size_t size, std::size_t stride) +{ + std::slice s(start, size, stride); + std::slice t = s; + return t.start() == start && t.size() == size && t.stride() == stride; +} + +bool +assignment(std::size_t start, std::size_t size, std::size_t stride) +{ + std::slice s(start, size, stride); + std::slice t; + t = s; + return t.start() == start && t.size() == size && t.stride() == stride; +} + + +int main() +{ + bool test __attribute__((unused)) = true; + std::srand(20020717); + using std::rand; + VERIFY(construction(rand(), rand(), rand())); + + VERIFY(copy(rand(), rand(), rand())); + + VERIFY(assignment(rand(), rand(), rand())); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/slice_array_assignment.cc b/libstdc++-v3/testsuite/26_numerics/valarray/slice_array_assignment.cc new file mode 100644 index 00000000000..2d5af920735 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/slice_array_assignment.cc @@ -0,0 +1,51 @@ +// 20010613 gdr + +// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + + +// This is DR-253. Test for accessible assignment-operators. +#include +#include + +int main() +{ + bool test __attribute__((unused)) = true; + using std::valarray; + using std::slice; + valarray v(1, 10), w(2, 10); + + w[slice(0, 3, 3)] = v[slice(2, 3, 3)]; + + VERIFY(v[0] == 1 && w[0] == 1); + VERIFY(v[3] == 1 && w[3] == 1); + VERIFY(v[6] == 1 && w[6] == 1); + + std::slice_array t = v[slice(0, 10, 1)]; + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/valarray.cc b/libstdc++-v3/testsuite/26_numerics/valarray/valarray.cc new file mode 100644 index 00000000000..37c9e0286e4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/valarray.cc @@ -0,0 +1,43 @@ +// 19990404 gdr + +// Copyright (C) 1999, 2000 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include + +int main() +{ + // 01: instantiation + std::valarray a(20); + + // 02: algo + using std::valarray; + valarray b, c; + double m __attribute__((unused)) = std::abs(b - c).max(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/valarray_const_bracket.cc b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_const_bracket.cc new file mode 100644 index 00000000000..53819f43ad1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_const_bracket.cc @@ -0,0 +1,48 @@ +// 20010518 gdr + +// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include + +// dg-do compile + +template + void copy(P, std::size_t) { } + +template + void test(const std::valarray& v) + { + copy(&v[0], v.size()); + } + +int main() +{ + std::valarray v(190); + test(v); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/valarray_name_lookup.cc b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_name_lookup.cc new file mode 100644 index 00000000000..a0bd21e791e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_name_lookup.cc @@ -0,0 +1,142 @@ +// 2002-08-02 gdr + +// Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// Test name lookup resolutions for standard functions applied to an +// array expression. +// { dg-do compile } + +#include + +namespace My +{ + struct Number + { + operator bool() const; + }; + + Number operator+(Number); + Number operator-(Number); + Number operator~(Number); + + bool operator!(Number); + + Number operator+(Number, Number); + Number operator-(Number, Number); + Number operator*(Number, Number); + Number operator/(Number, Number); + Number operator%(Number, Number); + + Number operator^(Number, Number); + Number operator&(Number, Number); + Number operator|(Number, Number); + + Number operator<<(Number, Number); + Number operator>>(Number, Number); + + bool operator==(Number, Number); + bool operator!=(Number, Number); + bool operator<(Number, Number); + bool operator<=(Number, Number); + bool operator>(Number, Number); + bool operator>=(Number, Number); + + Number abs(Number); + + Number cos(Number); + Number cosh(Number); + Number acos(Number); + + Number sin(Number); + Number sinh(Number); + Number asin(Number); + + Number tan(Number); + Number tanh(Number); + Number atan(Number); + + Number exp(Number); + Number log(Number); + Number log10(Number); + Number sqrt(Number); + + Number atan2(Number, Number); + Number pow(Number, Number); +} + +int main() +{ + typedef std::valarray Array; + Array u(10), v(10); + v = +u; + v = -u; + v = ~u; + std::valarray z = !u; + + v = abs(u); + + v = cos(u); + v = cosh(u); + v = acos(u); + + v = sin(u); + v = sinh(u); + v = asin(u); + + v = tan(u); + v = tanh(u); + v = atan(u); + + v = exp(u); + v = log(u); + v = log10(u); + v = sqrt(u); + + Array w = u + v; + w = u - v; + w = u * v; + w = u / v; + w = u % v; + + w = u ^ v; + w = u & v; + w = u | v; + + w = u << v; + w = u >> v; + + z = u == v; + z = u != v; + z = u < v; + z = u <= v; + z = u > v; + z = u >= v; + + w = atan2(u, v); + w = pow(u, v); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/valarray_operators.cc b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_operators.cc new file mode 100644 index 00000000000..16479a51241 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_operators.cc @@ -0,0 +1,69 @@ +// { dg-do run } +// 2003-02-03 Volker Reichelt + +// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include +#include + +void test01() // check unary operators +{ + bool test __attribute__((unused)) = true; + std::valarray u(1); + u[0]=1; + + VERIFY( (+u)[0] == +1 ); + VERIFY( (-u)[0] == -1 ); + VERIFY( (!u)[0] == !1 ); + VERIFY( (~u)[0] == ~1 ); +} + +void test02() // check binary operators +{ + bool test __attribute__((unused)) = true; + std::valarray u(1), v(1); + u[0]=1; + v[0]=3; + + VERIFY( (u+ v)[0] == (1+ 3) ); + VERIFY( (u- v)[0] == (1- 3) ); + VERIFY( (u* v)[0] == (1* 3) ); + VERIFY( (u/ v)[0] == (1/ 3) ); + VERIFY( (u% v)[0] == (1% 3) ); + VERIFY( (u^ v)[0] == (1^ 3) ); + VERIFY( (u& v)[0] == (1& 3) ); + VERIFY( (u| v)[0] == (1| 3) ); + VERIFY( (u<>v)[0] == (1>>3) ); + VERIFY( (u&&v)[0] == (1&&3) ); + VERIFY( (u||v)[0] == (1||3) ); + VERIFY( (u==v)[0] == (1==3) ); + VERIFY( (u!=v)[0] == (1!=3) ); + VERIFY( (u< v)[0] == (1< 3) ); + VERIFY( (u> v)[0] == (1> 3) ); + VERIFY( (u<=v)[0] == (1<=3) ); + VERIFY( (u>=v)[0] == (1>=3) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/valarray_subset_assignment.cc b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_subset_assignment.cc new file mode 100644 index 00000000000..9298bfb046f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/valarray_subset_assignment.cc @@ -0,0 +1,88 @@ +// 2004-01-03 Jerry Quinn + +// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// PR 3247 + +// This is DR-253. Test for accessible assignment-operators. +#include +#include + +bool check_array(std::valarray& a, double b[]) +{ + for (int i=0; i < a.size(); i++) + if (a[i] != b[i]) return false; + return true; +} + +int main() +{ + double dvar = 1.0; + std::valarray val_d(10); // 0 1 2 3 4 5 6 7 8 9 + std::valarray val_d1(10); // 10 9 8 7 6 5 4 3 2 1 + + for (int i=0; i< 10; i++) { val_d[i] = 10; val_d1[i] = i; } + std::valarray val_c(val_d); + std::valarray val_f(val_d); + std::valarray val_g(val_d); + + std::slice slc(1, 3, 3); // 1 4 7 + val_d[slc] = val_d1[slc]; + + double ans1[10] = {10, 1, 10, 10, 4, 10, 10, 7, 10, 10}; + VERIFY(check_array(val_d, ans1)); + + std::valarray val_size(2); + std::valarray val_stride(2); + val_size[0] = 2; val_size[1] = 3; + val_stride[0] = 4; val_stride[1] = 1; + + std::gslice gslc(1, val_size, val_stride); + val_c[gslc] = val_d1[gslc]; + + double ans2[10] = {10, 1, 2, 3, 10, 5, 6, 7, 10, 10}; + VERIFY(check_array(val_c, ans2)); + + std::valarray val_b(false, 10); + val_b[2] = val_b[6] = val_b[9] = true; + val_f[val_b] = val_d1[val_b]; + + double ans3[10] = {10, 10, 2, 10, 10, 10, 6, 10, 10, 9}; + VERIFY(check_array(val_f, ans3)); + + size_t addr[] = {1, 2, 3, 4, 5}; + size_t addr1[] = {2, 7, 1, 9, 4}; + std::valarray val_indirect(addr, 5); + std::valarray val_indirect1(addr1, 5); + val_g[val_indirect] = val_d1[val_indirect1]; + + double ans4[10] = {10, 2, 7, 1, 9, 4, 10, 10, 10, 10}; + VERIFY(check_array(val_g, ans4)); + + return 0; +}; diff --git a/libstdc++-v3/testsuite/26_numerics/valarray_const_bracket.cc b/libstdc++-v3/testsuite/26_numerics/valarray_const_bracket.cc deleted file mode 100644 index 53819f43ad1..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/valarray_const_bracket.cc +++ /dev/null @@ -1,48 +0,0 @@ -// 20010518 gdr - -// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#include - -// dg-do compile - -template - void copy(P, std::size_t) { } - -template - void test(const std::valarray& v) - { - copy(&v[0], v.size()); - } - -int main() -{ - std::valarray v(190); - test(v); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray_name_lookup.cc b/libstdc++-v3/testsuite/26_numerics/valarray_name_lookup.cc deleted file mode 100644 index a0bd21e791e..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/valarray_name_lookup.cc +++ /dev/null @@ -1,142 +0,0 @@ -// 2002-08-02 gdr - -// Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// Test name lookup resolutions for standard functions applied to an -// array expression. -// { dg-do compile } - -#include - -namespace My -{ - struct Number - { - operator bool() const; - }; - - Number operator+(Number); - Number operator-(Number); - Number operator~(Number); - - bool operator!(Number); - - Number operator+(Number, Number); - Number operator-(Number, Number); - Number operator*(Number, Number); - Number operator/(Number, Number); - Number operator%(Number, Number); - - Number operator^(Number, Number); - Number operator&(Number, Number); - Number operator|(Number, Number); - - Number operator<<(Number, Number); - Number operator>>(Number, Number); - - bool operator==(Number, Number); - bool operator!=(Number, Number); - bool operator<(Number, Number); - bool operator<=(Number, Number); - bool operator>(Number, Number); - bool operator>=(Number, Number); - - Number abs(Number); - - Number cos(Number); - Number cosh(Number); - Number acos(Number); - - Number sin(Number); - Number sinh(Number); - Number asin(Number); - - Number tan(Number); - Number tanh(Number); - Number atan(Number); - - Number exp(Number); - Number log(Number); - Number log10(Number); - Number sqrt(Number); - - Number atan2(Number, Number); - Number pow(Number, Number); -} - -int main() -{ - typedef std::valarray Array; - Array u(10), v(10); - v = +u; - v = -u; - v = ~u; - std::valarray z = !u; - - v = abs(u); - - v = cos(u); - v = cosh(u); - v = acos(u); - - v = sin(u); - v = sinh(u); - v = asin(u); - - v = tan(u); - v = tanh(u); - v = atan(u); - - v = exp(u); - v = log(u); - v = log10(u); - v = sqrt(u); - - Array w = u + v; - w = u - v; - w = u * v; - w = u / v; - w = u % v; - - w = u ^ v; - w = u & v; - w = u | v; - - w = u << v; - w = u >> v; - - z = u == v; - z = u != v; - z = u < v; - z = u <= v; - z = u > v; - z = u >= v; - - w = atan2(u, v); - w = pow(u, v); -} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray_operators.cc b/libstdc++-v3/testsuite/26_numerics/valarray_operators.cc deleted file mode 100644 index 16479a51241..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/valarray_operators.cc +++ /dev/null @@ -1,69 +0,0 @@ -// { dg-do run } -// 2003-02-03 Volker Reichelt - -// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -#include -#include - -void test01() // check unary operators -{ - bool test __attribute__((unused)) = true; - std::valarray u(1); - u[0]=1; - - VERIFY( (+u)[0] == +1 ); - VERIFY( (-u)[0] == -1 ); - VERIFY( (!u)[0] == !1 ); - VERIFY( (~u)[0] == ~1 ); -} - -void test02() // check binary operators -{ - bool test __attribute__((unused)) = true; - std::valarray u(1), v(1); - u[0]=1; - v[0]=3; - - VERIFY( (u+ v)[0] == (1+ 3) ); - VERIFY( (u- v)[0] == (1- 3) ); - VERIFY( (u* v)[0] == (1* 3) ); - VERIFY( (u/ v)[0] == (1/ 3) ); - VERIFY( (u% v)[0] == (1% 3) ); - VERIFY( (u^ v)[0] == (1^ 3) ); - VERIFY( (u& v)[0] == (1& 3) ); - VERIFY( (u| v)[0] == (1| 3) ); - VERIFY( (u<>v)[0] == (1>>3) ); - VERIFY( (u&&v)[0] == (1&&3) ); - VERIFY( (u||v)[0] == (1||3) ); - VERIFY( (u==v)[0] == (1==3) ); - VERIFY( (u!=v)[0] == (1!=3) ); - VERIFY( (u< v)[0] == (1< 3) ); - VERIFY( (u> v)[0] == (1> 3) ); - VERIFY( (u<=v)[0] == (1<=3) ); - VERIFY( (u>=v)[0] == (1>=3) ); -} - -int main() -{ - test01(); - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray_subset_assignment.cc b/libstdc++-v3/testsuite/26_numerics/valarray_subset_assignment.cc deleted file mode 100644 index 9298bfb046f..00000000000 --- a/libstdc++-v3/testsuite/26_numerics/valarray_subset_assignment.cc +++ /dev/null @@ -1,88 +0,0 @@ -// 2004-01-03 Jerry Quinn - -// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// PR 3247 - -// This is DR-253. Test for accessible assignment-operators. -#include -#include - -bool check_array(std::valarray& a, double b[]) -{ - for (int i=0; i < a.size(); i++) - if (a[i] != b[i]) return false; - return true; -} - -int main() -{ - double dvar = 1.0; - std::valarray val_d(10); // 0 1 2 3 4 5 6 7 8 9 - std::valarray val_d1(10); // 10 9 8 7 6 5 4 3 2 1 - - for (int i=0; i< 10; i++) { val_d[i] = 10; val_d1[i] = i; } - std::valarray val_c(val_d); - std::valarray val_f(val_d); - std::valarray val_g(val_d); - - std::slice slc(1, 3, 3); // 1 4 7 - val_d[slc] = val_d1[slc]; - - double ans1[10] = {10, 1, 10, 10, 4, 10, 10, 7, 10, 10}; - VERIFY(check_array(val_d, ans1)); - - std::valarray val_size(2); - std::valarray val_stride(2); - val_size[0] = 2; val_size[1] = 3; - val_stride[0] = 4; val_stride[1] = 1; - - std::gslice gslc(1, val_size, val_stride); - val_c[gslc] = val_d1[gslc]; - - double ans2[10] = {10, 1, 2, 3, 10, 5, 6, 7, 10, 10}; - VERIFY(check_array(val_c, ans2)); - - std::valarray val_b(false, 10); - val_b[2] = val_b[6] = val_b[9] = true; - val_f[val_b] = val_d1[val_b]; - - double ans3[10] = {10, 10, 2, 10, 10, 10, 6, 10, 10, 9}; - VERIFY(check_array(val_f, ans3)); - - size_t addr[] = {1, 2, 3, 4, 5}; - size_t addr1[] = {2, 7, 1, 9, 4}; - std::valarray val_indirect(addr, 5); - std::valarray val_indirect1(addr1, 5); - val_g[val_indirect] = val_d1[val_indirect1]; - - double ans4[10] = {10, 2, 7, 1, 9, 4, 10, 10, 10, 10}; - VERIFY(check_array(val_g, ans4)); - - return 0; -};