Skip to content

Commit

Permalink
Update tests to take promote_double policy into account
Browse files Browse the repository at this point in the history
Makes it easier to change its default to false in the future.
The remaining failing tests are test_nc_chi_squared
test_bessel_j_prime and test_bessel_y_prime.
They probably have incorrect logic for the double == long double
case already now.
  • Loading branch information
Reimar Döffinger authored and rdoeffinger committed Nov 18, 2024
1 parent f1b0b95 commit c4041a8
Show file tree
Hide file tree
Showing 42 changed files with 75 additions and 65 deletions.
2 changes: 1 addition & 1 deletion test/test_0F1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40";
}
Expand Down
5 changes: 4 additions & 1 deletion test/test_1F1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40|cpp_bin_float_double_extended";
}
Expand Down Expand Up @@ -71,6 +71,8 @@ void expected_results()
"Small.*", // test data group
".*", 1000, 300); // test function

if(boost::math::policies::promote_double<>())
{
#if (LDBL_MANT_DIG < DBL_MANT_DIG * 2) && (LDBL_MANT_DIG != DBL_MANT_DIG)
//
// long double has only a little extra precision and errors may creep
Expand Down Expand Up @@ -116,6 +118,7 @@ void expected_results()
".*", 10, 5); // test function

#endif
}

add_expected_result(
".*", // compiler
Expand Down
6 changes: 4 additions & 2 deletions test/test_1F1_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40|cpp_bin_float_double_extended";
}
Expand Down Expand Up @@ -72,6 +72,8 @@ void expected_results()
".*", 1000, 300); // test function

#if (LDBL_MANT_DIG < DBL_MANT_DIG * 2) && (LDBL_MANT_DIG != DBL_MANT_DIG)
if(boost::math::policies::promote_double<>())
{
//
// long double has only a little extra precision and errors may creep
// into the double results:
Expand Down Expand Up @@ -106,7 +108,7 @@ void expected_results()
"double", // test type(s)
"Bug.*", // test data group
".*", 300, 50); // test function

}
#endif

add_expected_result(
Expand Down
6 changes: 4 additions & 2 deletions test/test_1F1_regularized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40|cpp_bin_float_double_extended";
}
Expand Down Expand Up @@ -74,6 +74,8 @@ void expected_results()
".*", 1000, 300); // test function

#if (LDBL_MANT_DIG < DBL_MANT_DIG * 2) && (LDBL_MANT_DIG != DBL_MANT_DIG)
if(boost::math::policies::promote_double<>())
{
//
// long double has only a little extra precision and errors may creep
// into the double results:
Expand Down Expand Up @@ -108,7 +110,7 @@ void expected_results()
"double", // test type(s)
"Bug.*", // test data group
".*", 300, 50); // test function

}
#endif

add_expected_result(
Expand Down
4 changes: 2 additions & 2 deletions test/test_2F0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40";
}
Expand All @@ -29,7 +29,7 @@ void expected_results()
#endif

#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if (boost::math::policies::digits<double, boost::math::policies::policy<> >() != boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if (boost::math::policies::promote_double<>() && boost::math::policies::digits<double, boost::math::policies::policy<> >() != boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
add_expected_result(
".*", // compiler
Expand Down
2 changes: 1 addition & 1 deletion test/test_bessel_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_bessel_i_prime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
7 changes: 5 additions & 2 deletions test/test_bessel_j.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down Expand Up @@ -197,6 +197,8 @@ void expected_results()
BOOST_IF_CONSTEXPR ((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
&& (std::numeric_limits<long double>::digits < 90))
{
if (boost::math::policies::promote_double<>())
{
// some errors spill over into type double as well:
add_expected_result(
".*", // compiler
Expand Down Expand Up @@ -226,6 +228,7 @@ void expected_results()
"double", // test type(s)
".*", // test data group
".*", 30, 30); // test function
}
//
// and we have a few cases with higher limits as well:
//
Expand All @@ -251,7 +254,7 @@ void expected_results()
".*(JN|j).*|.*Tricky.*", // test data group
".*", 33000, 20000); // test function
}
else BOOST_IF_CONSTEXPR (std::numeric_limits<long double>::digits >= 90)
else BOOST_IF_CONSTEXPR (boost::math::policies::promote_double<>() && std::numeric_limits<long double>::digits >= 90)
{
add_expected_result(
".*", // compiler
Expand Down
4 changes: 2 additions & 2 deletions test/test_bessel_j_prime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down Expand Up @@ -177,7 +177,7 @@ void expected_results()


#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
if(boost::math::policies::promote_double<>() && (std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
&& (std::numeric_limits<long double>::digits < 90))
{
// some errors spill over into type double as well:
Expand Down
2 changes: 1 addition & 1 deletion test/test_bessel_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_bessel_k_prime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down
6 changes: 3 additions & 3 deletions test/test_bessel_y.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down Expand Up @@ -201,7 +201,7 @@ void expected_results()
".*", 2000, 2000); // test function

#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
BOOST_IF_CONSTEXPR((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
BOOST_IF_CONSTEXPR(boost::math::policies::promote_double<>() && (std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
&& (std::numeric_limits<long double>::digits < 90))
{
// some errors spill over into type double as well:
Expand All @@ -220,7 +220,7 @@ void expected_results()
".*Yv.*", // test data group
".*", 80, 70); // test function
}
else BOOST_IF_CONSTEXPR(std::numeric_limits<long double>::digits >= 90)
else BOOST_IF_CONSTEXPR(boost::math::policies::promote_double<>() && std::numeric_limits<long double>::digits >= 90)
{
add_expected_result(
".*", // compiler
Expand Down
4 changes: 2 additions & 2 deletions test/test_bessel_y_prime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down Expand Up @@ -220,7 +220,7 @@ void expected_results()
".*", 2000, 2000); // test function

#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
if(boost::math::policies::promote_double<>() && (std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
&& (std::numeric_limits<long double>::digits < 90))
{
// some errors spill over into type double as well:
Expand Down
2 changes: 1 addition & 1 deletion test/test_binomial_coeff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_carlson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_cbrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_ellint_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_ellint_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_ellint_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_ellint_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_gamma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_hermite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_heuman_lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_hypergeometric_dist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double|real_concept";
}
Expand All @@ -69,7 +69,7 @@ void expected_results()
largest_type = "(long\\s+)?double";
#endif
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if((boost::math::tools::digits<long double>() > boost::math::tools::digits<double>())
if(boost::math::policies::promote_double<>() && (boost::math::tools::digits<long double>() > boost::math::tools::digits<double>())
&& (boost::math::tools::digits<long double>() < 100))
{
//
Expand Down
2 changes: 1 addition & 1 deletion test/test_ibeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void expected_results()
//
const char* largest_type;
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
if(!boost::math::policies::promote_double<>() || boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
{
largest_type = "(long\\s+)?double";
}
Expand Down
Loading

0 comments on commit c4041a8

Please sign in to comment.