diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2012-07-20 22:18:27 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2012-07-20 22:18:27 +0000 |
| commit | f4e11de8e8495aa4e4ea649a9a2ed7c48dede7da (patch) | |
| tree | ca270168d14ddf86a748fb6d87008fa90439d71c /libcxx/test | |
| parent | f473cd4b6a48ef22e0f3d6ed91f471a41b34b01d (diff) | |
| download | bcm5719-llvm-f4e11de8e8495aa4e4ea649a9a2ed7c48dede7da.tar.gz bcm5719-llvm-f4e11de8e8495aa4e4ea649a9a2ed7c48dede7da.zip | |
constexpr applied to <complex>.
llvm-svn: 160585
Diffstat (limited to 'libcxx/test')
10 files changed, 113 insertions, 1 deletions
diff --git a/libcxx/test/numerics/complex.number/complex.members/construct.pass.cpp b/libcxx/test/numerics/complex.number/complex.members/construct.pass.cpp index 23374c5e961..b4d870fad11 100644 --- a/libcxx/test/numerics/complex.number/complex.members/construct.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.members/construct.pass.cpp @@ -9,7 +9,7 @@ // <complex> -// complex(const T& re = T(), const T& im = T()); +// constexpr complex(const T& re = T(), const T& im = T()); #include <complex> #include <cassert> @@ -38,6 +38,28 @@ test() assert(c.real() == 10.5); assert(c.imag() == -9.5); } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<T> c; + static_assert(c.real() == 0, ""); + static_assert(c.imag() == 0, ""); + } + { + constexpr std::complex<T> c = 7.5; + static_assert(c.real() == 7.5, ""); + static_assert(c.imag() == 0, ""); + } + { + constexpr std::complex<T> c(8.5); + static_assert(c.real() == 8.5, ""); + static_assert(c.imag() == 0, ""); + } + { + constexpr std::complex<T> c(10.5, -9.5); + static_assert(c.real() == 10.5, ""); + static_assert(c.imag() == -9.5, ""); + } +#endif } int main() diff --git a/libcxx/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp index 038e17107bf..e8d07ce287d 100644 --- a/libcxx/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<float> cd(2.5, 3.5); std::complex<double> cf(cd); assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<float> cd(2.5, 3.5); + constexpr std::complex<double> cf(cd); + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp index 197c6ceb5e6..298aaa3a7a8 100644 --- a/libcxx/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<float> cd(2.5, 3.5); std::complex<double> cf = cd; assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<float> cd(2.5, 3.5); + constexpr std::complex<double> cf = cd; + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp index 79c709e926f..6ff74a2cdef 100644 --- a/libcxx/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<long double> cd(2.5, 3.5); std::complex<double> cf(cd); assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<long double> cd(2.5, 3.5); + constexpr std::complex<double> cf(cd); + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp index 01002b35e16..77ca9d7f2aa 100644 --- a/libcxx/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<double> cd(2.5, 3.5); std::complex<float> cf(cd); assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<double> cd(2.5, 3.5); + constexpr std::complex<float> cf(cd); + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp index 9203fd5aeae..4fb11b4ca27 100644 --- a/libcxx/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<long double> cd(2.5, 3.5); std::complex<float> cf(cd); assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<long double> cd(2.5, 3.5); + constexpr std::complex<float> cf(cd); + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp index b604fd4b8c6..dd10c808b90 100644 --- a/libcxx/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<double> cd(2.5, 3.5); std::complex<long double> cf(cd); assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<double> cd(2.5, 3.5); + constexpr std::complex<long double> cf(cd); + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp index 14eff25e7b4..aab539407d0 100644 --- a/libcxx/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<double> cd(2.5, 3.5); std::complex<long double> cf = cd; assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<double> cd(2.5, 3.5); + constexpr std::complex<long double> cf = cd; + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp index 5414f348af1..a5f5101c4dc 100644 --- a/libcxx/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<float> cd(2.5, 3.5); std::complex<long double> cf(cd); assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<float> cd(2.5, 3.5); + constexpr std::complex<long double> cf(cd); + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } diff --git a/libcxx/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp b/libcxx/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp index a0021782fe2..25b93823f6e 100644 --- a/libcxx/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp +++ b/libcxx/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp @@ -20,8 +20,18 @@ int main() { + { const std::complex<float> cd(2.5, 3.5); std::complex<long double> cf = cd; assert(cf.real() == cd.real()); assert(cf.imag() == cd.imag()); + } +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + { + constexpr std::complex<float> cd(2.5, 3.5); + constexpr std::complex<long double> cf = cd; + static_assert(cf.real() == cd.real(), ""); + static_assert(cf.imag() == cd.imag(), ""); + } +#endif } |

