diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 481e264974c..93b2e0a11f8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2006-01-15 Paolo Carlini + + * testsuite/tr1/8_c_compatibility/complex/overloads_int.cc: + Fix norm test, use casts everywhere. + 2006-01-14 Paolo Carlini * testsuite/testsuite_tr1.h: Add missing include; use std::__are_same. diff --git a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc index c5fcd84cf9d..07b2f924d95 100644 --- a/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc +++ b/libstdc++-v3/testsuite/tr1/8_c_compatibility/complex/overloads_int.cc @@ -37,53 +37,59 @@ void test01() const unsigned u1 = 1; const long l1 = 1; const double f1 = 1.0f; - const double d0 = 0.0; const double d1 = 1.0; check_ret_type(arg(i1)); - VERIFY( arg(i1) == arg(d1) ); - VERIFY( arg(i1) == arg(cmplx_d_type(d1, d0)) ); + VERIFY( arg(i1) == arg(double(i1)) ); + VERIFY( arg(i1) == arg(cmplx_d_type(double(i1))) ); check_ret_type(conj(i1)); - VERIFY( conj(i1) == conj(d1) ); - VERIFY( conj(i1) == conj(cmplx_d_type(d1, d0)) ); + VERIFY( conj(i1) == conj(double(i1)) ); + VERIFY( conj(i1) == conj(cmplx_d_type(double(i1))) ); check_ret_type(imag(i1)); - VERIFY( imag(i1) == imag(d1) ); - VERIFY( imag(i1) == imag(cmplx_d_type(d1, d0)) ); + VERIFY( imag(i1) == imag(double(i1)) ); + VERIFY( imag(i1) == imag(cmplx_d_type(double(i1))) ); check_ret_type(norm(i1)); - VERIFY( norm(i1) == norm(d1) ); - VERIFY( norm(i1) == norm(cmplx_d_type(d1, d0)) ); + VERIFY( norm(i1) == norm(double(i1)) ); + // std::norm&) is mathematically equivalent to just + // this for a real, but the general algorithm goes through std::abs + // and a multiplication. + VERIFY( norm(i1) == double(i1) * double(i1) ); check_ret_type(polar(i1, i1)); - VERIFY( polar(i1, i1) == polar(d1, d1) ); - - // NB: According to the letter of 8.1.9/3 the return type - // should be a cmplx_d_type, but the existing overload - // std::pow(const complex<>&, int) wins. + VERIFY( polar(i1, i1) == polar(double(i1), double(i1)) ); + // NB: According to the letter of 8.1.9/3 the return type should be a + // cmplx_d_type, but the existing std::pow(const complex<>&, int) wins. check_ret_type(pow(cmplx_f_type(f1, f1), i1)); check_ret_type(pow(cmplx_f_type(f1, f1), u1)); check_ret_type(pow(cmplx_f_type(f1, f1), l1)); check_ret_type(pow(cmplx_d_type(d1, d1), i1)); - // See above comment. - // VERIFY( pow(cmplx_d_type(d1, d1), i1) == pow(cmplx_d_type(d1, d1), d1) ); - VERIFY( pow(cmplx_d_type(d1, d1), u1) == pow(cmplx_d_type(d1, d1), d1) ); - VERIFY( pow(cmplx_d_type(d1, d1), l1) == pow(cmplx_d_type(d1, d1), d1) ); + // See last comment. + // VERIFY( pow(cmplx_d_type(d1, d1), i1) + // == pow(cmplx_d_type(d1, d1), double(i1)) ); + VERIFY( pow(cmplx_d_type(d1, d1), u1) + == pow(cmplx_d_type(d1, d1), double(u1)) ); + VERIFY( pow(cmplx_d_type(d1, d1), l1) + == pow(cmplx_d_type(d1, d1), double(l1)) ); check_ret_type(pow(i1, cmplx_f_type(f1, f1))); check_ret_type(pow(u1, cmplx_f_type(f1, f1))); check_ret_type(pow(l1, cmplx_f_type(f1, f1))); check_ret_type(pow(i1, cmplx_d_type(d1, d1))); - VERIFY( pow(i1, cmplx_d_type(d1, d1)) == pow(d1, cmplx_d_type(d1, d1)) ); - VERIFY( pow(u1, cmplx_d_type(d1, d1)) == pow(d1, cmplx_d_type(d1, d1)) ); - VERIFY( pow(l1, cmplx_d_type(d1, d1)) == pow(d1, cmplx_d_type(d1, d1)) ); + VERIFY( pow(i1, cmplx_d_type(d1, d1)) + == pow(double(i1), cmplx_d_type(d1, d1)) ); + VERIFY( pow(u1, cmplx_d_type(d1, d1)) + == pow(double(u1), cmplx_d_type(d1, d1)) ); + VERIFY( pow(l1, cmplx_d_type(d1, d1)) + == pow(double(l1), cmplx_d_type(d1, d1)) ); check_ret_type(real(i1)); - VERIFY( real(i1) == real(d1) ); - VERIFY( real(i1) == real(cmplx_d_type(d1, d1)) ); + VERIFY( real(i1) == real(double(i1)) ); + VERIFY( real(i1) == real(cmplx_d_type(double(i1))) ); } int main()