Skip to content

Commit

Permalink
complex abs return type test; fixes #1836
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Carpenter committed Apr 13, 2020
1 parent 4b3eb6f commit 8ccdd28
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/unit/math/mix/fun/abs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#include <cmath>
#include <complex>
#include <vector>
#include <type_traits>

TEST(mixScalFun, abs) {
TEST(mixFun, abs) {
auto f = [](const auto& x) {
using std::abs;
return abs(x);
Expand All @@ -29,3 +30,12 @@ TEST(mixScalFun, abs) {
}
}
}
TEST(mixFun, absReturnType) {
// validate return types not overpromoted to complex by assignability
std::complex<stan::math::var> a = 3;
stan::math::var b = abs(a);

std::complex<stan::math::fvar<double>> c = 3;
stan::math::fvar<double> d = abs(c);
SUCCEED();
}

0 comments on commit 8ccdd28

Please sign in to comment.