summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics/complex.number
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/numerics/complex.number')
-rw-r--r--libcxx/test/std/numerics/complex.number/cases.h230
-rw-r--r--libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp21
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp55
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp66
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp67
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp55
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp104
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp66
-rw-r--r--libcxx/test/std/numerics/complex.number/cmplx.over/real.pass.cpp67
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.literals/literals.pass.cpp51
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp20
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp43
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp43
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp48
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp53
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp44
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp52
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp40
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp52
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp40
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp52
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp44
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.members/construct.pass.cpp70
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp64
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp159
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp41
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp60
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp81
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp49
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp49
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp62
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp81
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp49
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp49
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp161
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp41
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp41
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp81
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp49
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp81
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp49
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp41
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp99
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp26
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp36
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp36
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp27
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp27
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp27
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp37
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp140
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp142
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp120
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp119
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp68
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp132
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp68
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp118
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp114
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp131
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp66
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp71
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp69
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp69
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp69
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp119
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp109
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp70
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp101
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp63
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp135
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp41
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp32
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp63
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp112
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp71
-rw-r--r--libcxx/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp32
-rw-r--r--libcxx/test/std/numerics/complex.number/complex/types.pass.cpp36
-rw-r--r--libcxx/test/std/numerics/complex.number/layout.pass.cpp36
-rw-r--r--libcxx/test/std/numerics/complex.number/version.pass.cpp20
90 files changed, 5867 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/complex.number/cases.h b/libcxx/test/std/numerics/complex.number/cases.h
new file mode 100644
index 00000000000..cd6bd165a9d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cases.h
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// test cases
+
+#ifndef CASES_H
+#define CASES_H
+
+#include <complex>
+#include <cassert>
+
+std::complex<double> x[] =
+{
+ std::complex<double>( 1.e-6, 1.e-6),
+ std::complex<double>(-1.e-6, 1.e-6),
+ std::complex<double>(-1.e-6, -1.e-6),
+ std::complex<double>( 1.e-6, -1.e-6),
+
+ std::complex<double>( 1.e+6, 1.e-6),
+ std::complex<double>(-1.e+6, 1.e-6),
+ std::complex<double>(-1.e+6, -1.e-6),
+ std::complex<double>( 1.e+6, -1.e-6),
+
+ std::complex<double>( 1.e-6, 1.e+6),
+ std::complex<double>(-1.e-6, 1.e+6),
+ std::complex<double>(-1.e-6, -1.e+6),
+ std::complex<double>( 1.e-6, -1.e+6),
+
+ std::complex<double>( 1.e+6, 1.e+6),
+ std::complex<double>(-1.e+6, 1.e+6),
+ std::complex<double>(-1.e+6, -1.e+6),
+ std::complex<double>( 1.e+6, -1.e+6),
+
+ std::complex<double>(NAN, NAN),
+ std::complex<double>(-INFINITY, NAN),
+ std::complex<double>(-2, NAN),
+ std::complex<double>(-1, NAN),
+ std::complex<double>(-0.5, NAN),
+ std::complex<double>(-0., NAN),
+ std::complex<double>(+0., NAN),
+ std::complex<double>(0.5, NAN),
+ std::complex<double>(1, NAN),
+ std::complex<double>(2, NAN),
+ std::complex<double>(INFINITY, NAN),
+
+ std::complex<double>(NAN, -INFINITY),
+ std::complex<double>(-INFINITY, -INFINITY),
+ std::complex<double>(-2, -INFINITY),
+ std::complex<double>(-1, -INFINITY),
+ std::complex<double>(-0.5, -INFINITY),
+ std::complex<double>(-0., -INFINITY),
+ std::complex<double>(+0., -INFINITY),
+ std::complex<double>(0.5, -INFINITY),
+ std::complex<double>(1, -INFINITY),
+ std::complex<double>(2, -INFINITY),
+ std::complex<double>(INFINITY, -INFINITY),
+
+ std::complex<double>(NAN, -2),
+ std::complex<double>(-INFINITY, -2),
+ std::complex<double>(-2, -2),
+ std::complex<double>(-1, -2),
+ std::complex<double>(-0.5, -2),
+ std::complex<double>(-0., -2),
+ std::complex<double>(+0., -2),
+ std::complex<double>(0.5, -2),
+ std::complex<double>(1, -2),
+ std::complex<double>(2, -2),
+ std::complex<double>(INFINITY, -2),
+
+ std::complex<double>(NAN, -1),
+ std::complex<double>(-INFINITY, -1),
+ std::complex<double>(-2, -1),
+ std::complex<double>(-1, -1),
+ std::complex<double>(-0.5, -1),
+ std::complex<double>(-0., -1),
+ std::complex<double>(+0., -1),
+ std::complex<double>(0.5, -1),
+ std::complex<double>(1, -1),
+ std::complex<double>(2, -1),
+ std::complex<double>(INFINITY, -1),
+
+ std::complex<double>(NAN, -0.5),
+ std::complex<double>(-INFINITY, -0.5),
+ std::complex<double>(-2, -0.5),
+ std::complex<double>(-1, -0.5),
+ std::complex<double>(-0.5, -0.5),
+ std::complex<double>(-0., -0.5),
+ std::complex<double>(+0., -0.5),
+ std::complex<double>(0.5, -0.5),
+ std::complex<double>(1, -0.5),
+ std::complex<double>(2, -0.5),
+ std::complex<double>(INFINITY, -0.5),
+
+ std::complex<double>(NAN, -0.),
+ std::complex<double>(-INFINITY, -0.),
+ std::complex<double>(-2, -0.),
+ std::complex<double>(-1, -0.),
+ std::complex<double>(-0.5, -0.),
+ std::complex<double>(-0., -0.),
+ std::complex<double>(+0., -0.),
+ std::complex<double>(0.5, -0.),
+ std::complex<double>(1, -0.),
+ std::complex<double>(2, -0.),
+ std::complex<double>(INFINITY, -0.),
+
+ std::complex<double>(NAN, +0.),
+ std::complex<double>(-INFINITY, +0.),
+ std::complex<double>(-2, +0.),
+ std::complex<double>(-1, +0.),
+ std::complex<double>(-0.5, +0.),
+ std::complex<double>(-0., +0.),
+ std::complex<double>(+0., +0.),
+ std::complex<double>(0.5, +0.),
+ std::complex<double>(1, +0.),
+ std::complex<double>(2, +0.),
+ std::complex<double>(INFINITY, +0.),
+
+ std::complex<double>(NAN, 0.5),
+ std::complex<double>(-INFINITY, 0.5),
+ std::complex<double>(-2, 0.5),
+ std::complex<double>(-1, 0.5),
+ std::complex<double>(-0.5, 0.5),
+ std::complex<double>(-0., 0.5),
+ std::complex<double>(+0., 0.5),
+ std::complex<double>(0.5, 0.5),
+ std::complex<double>(1, 0.5),
+ std::complex<double>(2, 0.5),
+ std::complex<double>(INFINITY, 0.5),
+
+ std::complex<double>(NAN, 1),
+ std::complex<double>(-INFINITY, 1),
+ std::complex<double>(-2, 1),
+ std::complex<double>(-1, 1),
+ std::complex<double>(-0.5, 1),
+ std::complex<double>(-0., 1),
+ std::complex<double>(+0., 1),
+ std::complex<double>(0.5, 1),
+ std::complex<double>(1, 1),
+ std::complex<double>(2, 1),
+ std::complex<double>(INFINITY, 1),
+
+ std::complex<double>(NAN, 2),
+ std::complex<double>(-INFINITY, 2),
+ std::complex<double>(-2, 2),
+ std::complex<double>(-1, 2),
+ std::complex<double>(-0.5, 2),
+ std::complex<double>(-0., 2),
+ std::complex<double>(+0., 2),
+ std::complex<double>(0.5, 2),
+ std::complex<double>(1, 2),
+ std::complex<double>(2, 2),
+ std::complex<double>(INFINITY, 2),
+
+ std::complex<double>(NAN, INFINITY),
+ std::complex<double>(-INFINITY, INFINITY),
+ std::complex<double>(-2, INFINITY),
+ std::complex<double>(-1, INFINITY),
+ std::complex<double>(-0.5, INFINITY),
+ std::complex<double>(-0., INFINITY),
+ std::complex<double>(+0., INFINITY),
+ std::complex<double>(0.5, INFINITY),
+ std::complex<double>(1, INFINITY),
+ std::complex<double>(2, INFINITY),
+ std::complex<double>(INFINITY, INFINITY)
+};
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+template <class T>
+int
+classify(const std::complex<T>& x)
+{
+ if (x == std::complex<T>())
+ return zero;
+ if (std::isinf(x.real()) || std::isinf(x.imag()))
+ return inf;
+ if (std::isnan(x.real()) && std::isnan(x.imag()))
+ return NaN;
+ if (std::isnan(x.real()))
+ {
+ if (x.imag() == T(0))
+ return NaN;
+ return non_zero_nan;
+ }
+ if (std::isnan(x.imag()))
+ {
+ if (x.real() == T(0))
+ return NaN;
+ return non_zero_nan;
+ }
+ return non_zero;
+}
+
+inline
+int
+classify(double x)
+{
+ if (x == 0)
+ return zero;
+ if (std::isinf(x))
+ return inf;
+ if (std::isnan(x))
+ return NaN;
+ return non_zero;
+}
+
+void is_about(float x, float y)
+{
+ assert(std::abs((x-y)/(x+y)) < 1.e-6);
+}
+
+void is_about(double x, double y)
+{
+ assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+void is_about(long double x, long double y)
+{
+ assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+#endif // CASES_H
diff --git a/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp b/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
new file mode 100644
index 00000000000..21aaa669fd4
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <ccomplex>
+
+#include <ccomplex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+ std::complex<double> d;
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
new file mode 100644
index 00000000000..978c6255ac3
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// arg(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::arg(x)), double>::value), "");
+ assert(std::arg(x) == arg(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::arg(x)), T>::value), "");
+ assert(std::arg(x) == arg(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp
new file mode 100644
index 00000000000..6adbf21ec26
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/conj.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> complex<T> conj(const complex<T>&);
+// complex<long double> conj(long double);
+// complex<double> conj(double);
+// template<Integral T> complex<double> conj(T);
+// complex<float> conj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::conj(x)), std::complex<double> >::value), "");
+ assert(std::conj(x) == conj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+ assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+ !std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+ assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp
new file mode 100644
index 00000000000..30c95c3c88d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/imag.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// imag(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T, int x>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::imag(T(x))), double>::value), "");
+ assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::imag(val) == 0, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.imag() == x, "" );
+#endif
+}
+
+template <class T, int x>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::imag(T(x))), T>::value), "");
+ assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::imag(val) == 0, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.imag() == x, "" );
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ test<T, 0>();
+ test<T, 1>();
+ test<T, 10>();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
new file mode 100644
index 00000000000..badd5c0cc85
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// norm(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::norm(x)), double>::value), "");
+ assert(std::norm(x) == norm(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::norm(x)), T>::value), "");
+ assert(std::norm(x) == norm(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp
new file mode 100644
index 00000000000..3b1e9b34b35
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/pow.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T, Arithmetic U>
+// complex<promote<T, U>::type>
+// pow(const T& x, const complex<U>& y);
+
+// template<Arithmetic T, Arithmetic U>
+// complex<promote<T, U>::type>
+// pow(const complex<T>& x, const U& y);
+
+// template<Arithmetic T, Arithmetic U>
+// complex<promote<T, U>::type>
+// pow(const complex<T>& x, const complex<U>& y);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+double
+promote(T, typename std::enable_if<std::is_integral<T>::value>::type* = 0);
+
+float promote(float);
+double promote(double);
+long double promote(long double);
+
+template <class T, class U>
+void
+test(T x, const std::complex<U>& y)
+{
+ typedef decltype(promote(x)+promote(real(y))) V;
+ static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+ assert(std::pow(x, y) == pow(std::complex<V>(x, 0), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, U y)
+{
+ typedef decltype(promote(real(x))+promote(y)) V;
+ static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+ assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y, 0)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, const std::complex<U>& y)
+{
+ typedef decltype(promote(real(x))+promote(real(y))) V;
+ static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+ assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+ test(T(3), std::complex<U>(4, 5));
+ test(std::complex<U>(3, 4), T(5));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+ test(T(3), std::complex<U>(4, 5));
+ test(std::complex<T>(3, 4), U(5));
+ test(std::complex<T>(3, 4), std::complex<U>(5, 6));
+}
+
+int main()
+{
+ test<int, float>();
+ test<int, double>();
+ test<int, long double>();
+
+ test<unsigned, float>();
+ test<unsigned, double>();
+ test<unsigned, long double>();
+
+ test<long long, float>();
+ test<long long, double>();
+ test<long long, long double>();
+
+ test<float, double>();
+ test<float, long double>();
+
+ test<double, float>();
+ test<double, long double>();
+
+ test<long double, float>();
+ test<long double, double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp
new file mode 100644
index 00000000000..60d6e7223e5
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/proj.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T> complex<T> proj(const complex<T>&);
+// complex<long double> proj(long double);
+// complex<double> proj(double);
+// template<Integral T> complex<double> proj(T);
+// complex<float> proj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::proj(x)), std::complex<double> >::value), "");
+ assert(std::proj(x) == proj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+ assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+ !std::is_floating_point<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+ assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+ test<T>(0);
+ test<T>(1);
+ test<T>(10);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/cmplx.over/real.pass.cpp b/libcxx/test/std/numerics/complex.number/cmplx.over/real.pass.cpp
new file mode 100644
index 00000000000..a5a4a35b13c
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/cmplx.over/real.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+// T
+// real(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T, int x>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::real(T(x))), double>::value), "");
+ assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::real(val) == val, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.real() == x, "" );
+#endif
+}
+
+template <class T, int x>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+ static_assert((std::is_same<decltype(std::real(T(x))), T>::value), "");
+ assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+ constexpr T val {x};
+ static_assert(std::real(val) == val, "");
+ constexpr std::complex<T> t{val, val};
+ static_assert(t.real() == x, "" );
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ test<T, 0>();
+ test<T, 1>();
+ test<T, 10>();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test<int>();
+ test<unsigned>();
+ test<long long>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.literals/literals.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.literals/literals.pass.cpp
new file mode 100644
index 00000000000..45b59914e7f
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.literals/literals.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals::complex_literals;
+
+// Make sure the types are right
+ static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3il ), std::complex<long double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3.0i ), std::complex<double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3i ), std::complex<double>>::value, "" );
+ static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
+ static_assert ( std::is_same<decltype( 3if ), std::complex<float>>::value, "" );
+
+ {
+ std::complex<long double> c1 = 3.0il;
+ assert ( c1 == std::complex<long double>(0, 3.0));
+ auto c2 = 3il;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<double> c1 = 3.0i;
+ assert ( c1 == std::complex<double>(0, 3.0));
+ auto c2 = 3i;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<float> c1 = 3.0if;
+ assert ( c1 == std::complex<float>(0, 3.0));
+ auto c2 = 3if;
+ assert ( c1 == c2 );
+ }
+
+#endif
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp b/libcxx/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp
new file mode 100644
index 00000000000..0f31d595566
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <complex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ std::complex<float> foo = 1.0if; // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp
new file mode 100644
index 00000000000..46903bbd565
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.literals/literals1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std::literals;
+
+ {
+ std::complex<long double> c1 = 3.0il;
+ assert ( c1 == std::complex<long double>(0, 3.0));
+ auto c2 = 3il;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<double> c1 = 3.0i;
+ assert ( c1 == std::complex<double>(0, 3.0));
+ auto c2 = 3i;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<float> c1 = 3.0if;
+ assert ( c1 == std::complex<float>(0, 3.0));
+ auto c2 = 3if;
+ assert ( c1 == c2 );
+ }
+
+#endif
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp
new file mode 100644
index 00000000000..8bd8acd981b
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.literals/literals2.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ using namespace std;
+
+ {
+ std::complex<long double> c1 = 3.0il;
+ assert ( c1 == std::complex<long double>(0, 3.0));
+ auto c2 = 3il;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<double> c1 = 3.0i;
+ assert ( c1 == std::complex<double>(0, 3.0));
+ auto c2 = 3i;
+ assert ( c1 == c2 );
+ }
+
+ {
+ std::complex<float> c1 = 3.0if;
+ assert ( c1 == std::complex<float>(0, 3.0));
+ auto c2 = 3if;
+ assert ( c1 == c2 );
+ }
+
+#endif
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
new file mode 100644
index 00000000000..d3942942796
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator=(const complex&);
+// template<class X> complex& operator= (const complex<X>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T, class X>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ std::complex<T> c2(1.5, 2.5);
+ c = c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ std::complex<X> c3(3.5, -4.5);
+ c = c3;
+ assert(c.real() == 3.5);
+ assert(c.imag() == -4.5);
+}
+
+int main()
+{
+ test<float, float>();
+ test<float, double>();
+ test<float, long double>();
+
+ test<double, float>();
+ test<double, double>();
+ test<double, long double>();
+
+ test<long double, float>();
+ test<long double, double>();
+ test<long double, long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
new file mode 100644
index 00000000000..87b78061e53
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator= (const T&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c = 1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+ c = -1.5;
+ assert(c.real() == -1.5);
+ assert(c.imag() == 0);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
new file mode 100644
index 00000000000..cb285117b15
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(-4, 7.5);
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == -4);
+ assert(c.imag() == 7.5);
+ c /= c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ c /= c2;
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 /= ic;
+ assert(c3.real() == 0.5);
+ assert(c3.imag() == -0.5);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 /= fc;
+ assert(c3.real() == 0.5);
+ assert(c3.imag() == -0.5);
+
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
new file mode 100644
index 00000000000..89907d13a45
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(1);
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+ c /= 0.5;
+ assert(c.real() == 2);
+ assert(c.imag() == 0);
+ c /= 0.5;
+ assert(c.real() == 4);
+ assert(c.imag() == 0);
+ c /= -0.5;
+ assert(c.real() == -8);
+ assert(c.imag() == 0);
+ c.imag(2);
+ c /= 0.5;
+ assert(c.real() == -16);
+ assert(c.imag() == 4);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
new file mode 100644
index 00000000000..67a1c7189a2
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c -= c2;
+ assert(c.real() == -1.5);
+ assert(c.imag() == -2.5);
+ c -= c2;
+ assert(c.real() == -3);
+ assert(c.imag() == -5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 -= ic;
+ assert(c3.real() == -4);
+ assert(c3.imag() == -6);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 -= fc;
+ assert(c3.real() == -4);
+ assert(c3.imag() == -6);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
new file mode 100644
index 00000000000..ddec891b25a
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c -= 1.5;
+ assert(c.real() == -1.5);
+ assert(c.imag() == 0);
+ c -= 1.5;
+ assert(c.real() == -3);
+ assert(c.imag() == 0);
+ c -= -1.5;
+ assert(c.real() == -1.5);
+ assert(c.imag() == 0);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
new file mode 100644
index 00000000000..8c16f4ced2c
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c += c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ c += c2;
+ assert(c.real() == 3);
+ assert(c.imag() == 5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 += ic;
+ assert(c3.real() == 4);
+ assert(c3.imag() == 6);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 += fc;
+ assert(c3.real() == 4);
+ assert(c3.imag() == 6);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
new file mode 100644
index 00000000000..4dd8066d126
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c += 1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+ c += 1.5;
+ assert(c.real() == 3);
+ assert(c.imag() == 0);
+ c += -1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
new file mode 100644
index 00000000000..84d6e591306
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(1);
+ const std::complex<T> c2(1.5, 2.5);
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+ c *= c2;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+ c *= c2;
+ assert(c.real() == -4);
+ assert(c.imag() == 7.5);
+
+ std::complex<T> c3;
+
+ c3 = c;
+ std::complex<int> ic (1,1);
+ c3 *= ic;
+ assert(c3.real() == -11.5);
+ assert(c3.imag() == 3.5);
+
+ c3 = c;
+ std::complex<float> fc (1,1);
+ c3 *= fc;
+ assert(c3.real() == -11.5);
+ assert(c3.imag() == 3.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
new file mode 100644
index 00000000000..c94baa9b623
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c(1);
+ assert(c.real() == 1);
+ assert(c.imag() == 0);
+ c *= 1.5;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 0);
+ c *= 1.5;
+ assert(c.real() == 2.25);
+ assert(c.imag() == 0);
+ c *= -1.5;
+ assert(c.real() == -3.375);
+ assert(c.imag() == 0);
+ c.imag(2);
+ c *= 1.5;
+ assert(c.real() == -5.0625);
+ assert(c.imag() == 3);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.members/construct.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.members/construct.pass.cpp
new file mode 100644
index 00000000000..b4d870fad11
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.members/construct.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// constexpr complex(const T& re = T(), const T& im = T());
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ {
+ const std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ }
+ {
+ const std::complex<T> c = 7.5;
+ assert(c.real() == 7.5);
+ assert(c.imag() == 0);
+ }
+ {
+ const std::complex<T> c(8.5);
+ assert(c.real() == 8.5);
+ assert(c.imag() == 0);
+ }
+ {
+ const std::complex<T> c(10.5, -9.5);
+ 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()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp
new file mode 100644
index 00000000000..7ead855f5c7
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.members/real_imag.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// void real(T val);
+// void imag(T val);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ constexpr std::complex<T> c1;
+ static_assert(c1.real() == 0, "");
+ static_assert(c1.imag() == 0, "");
+ constexpr std::complex<T> c2(3);
+ static_assert(c2.real() == 3, "");
+ static_assert(c2.imag() == 0, "");
+ constexpr std::complex<T> c3(3, 4);
+ static_assert(c3.real() == 3, "");
+ static_assert(c3.imag() == 4, "");
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> c;
+ assert(c.real() == 0);
+ assert(c.imag() == 0);
+ c.real(3.5);
+ assert(c.real() == 3.5);
+ assert(c.imag() == 0);
+ c.imag(4.5);
+ assert(c.real() == 3.5);
+ assert(c.imag() == 4.5);
+ c.real(-4.5);
+ assert(c.real() == -4.5);
+ assert(c.imag() == 4.5);
+ c.imag(-5.5);
+ assert(c.real() == -4.5);
+ assert(c.imag() == -5.5);
+
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_constexpr<int> ();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
new file mode 100644
index 00000000000..86119678aa7
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator/(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(-4.0, 7.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(1.5, 2.5);
+ test(lhs, rhs, x);
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = x[i] / x[j];
+ switch (classify(x[i]))
+ {
+ case zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == zero);
+ break;
+ case inf:
+ assert(classify(r) == zero);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == inf);
+ break;
+ case non_zero:
+ assert(classify(r) == non_zero);
+ break;
+ case inf:
+ assert(classify(r) == zero);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == inf);
+ break;
+ case non_zero:
+ assert(classify(r) == inf);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == inf);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
new file mode 100644
index 00000000000..b23b381cb59
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator/(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(-4.0, 7.5);
+ T rhs(2);
+ std::complex<T> x(-2, 3.75);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
new file mode 100644
index 00000000000..970f021f8e6
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator==(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, -2.5);
+ static_assert( !(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(lhs == rhs, "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, -2.5);
+ assert( !(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(lhs == rhs);
+ }
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
new file mode 100644
index 00000000000..3c8b772bcaa
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator==(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(-2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(-2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(1.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(1.5);
+ static_assert( (lhs == rhs), "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(-2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(-2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(1.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(1.5);
+ assert( (lhs == rhs));
+ }
+
+ test_constexpr<T> ();
+ }
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
new file mode 100644
index 00000000000..b2cddd26d8b
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(-2.0, -2.0);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(5.0, -7.0);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
new file mode 100644
index 00000000000..b630679fc98
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(3.5);
+ std::complex<T> x(-2.0, 2.5);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ T rhs(-3.5);
+ std::complex<T> x(5.0, -2.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
new file mode 100644
index 00000000000..ee138c1ecbc
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator!=(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, -2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs != rhs), "" );
+ }
+#endif
+}
+
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, -2.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(!(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
+ }
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
new file mode 100644
index 00000000000..efb1c0e872d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator!=(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(-2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(-2.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 2.5);
+ constexpr T rhs(1.5);
+ static_assert(lhs != rhs, "");
+ }
+ {
+ constexpr std::complex<T> lhs(1.5, 0);
+ constexpr T rhs(1.5);
+ static_assert( !(lhs != rhs), "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(-2.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(-2.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(1.5);
+ assert(lhs != rhs);
+ }
+ {
+ std::complex<T> lhs(1.5, 0);
+ T rhs(1.5);
+ assert( !(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int> ();
+ }
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
new file mode 100644
index 00000000000..02ed8684ea9
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(5.0, 7.0);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(-2.0, 2.0);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
new file mode 100644
index 00000000000..eeec83fb09a
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(3.5);
+ std::complex<T> x(5.0, 2.5);
+ test(lhs, rhs, x);
+ }
+ {
+ std::complex<T> lhs(1.5, -2.5);
+ T rhs(-3.5);
+ std::complex<T> x(-2.0, -2.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
new file mode 100644
index 00000000000..565eaa5657c
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
@@ -0,0 +1,161 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator*(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(1.5, 2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(-4.0, 7.5);
+ test(lhs, rhs, x);
+}
+
+// test edges
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = x[i] * x[j];
+ switch (classify(x[i]))
+ {
+ case zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == zero);
+ break;
+ case non_zero:
+ assert(classify(r) == zero);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == zero);
+ break;
+ case non_zero:
+ assert(classify(r) == non_zero);
+ break;
+ case inf:
+ assert(classify(r) == inf);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case inf:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == inf);
+ break;
+ case inf:
+ assert(classify(r) == inf);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == inf);
+ break;
+ }
+ break;
+ case NaN:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == NaN);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ case non_zero_nan:
+ switch (classify(x[j]))
+ {
+ case zero:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero:
+ assert(classify(r) == NaN);
+ break;
+ case inf:
+ assert(classify(r) == inf);
+ break;
+ case NaN:
+ assert(classify(r) == NaN);
+ break;
+ case non_zero_nan:
+ assert(classify(r) == NaN);
+ break;
+ }
+ break;
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
new file mode 100644
index 00000000000..0e829a4caa6
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator*(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+ assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ std::complex<T> lhs(1.5, 2.5);
+ T rhs(1.5);
+ std::complex<T> x(2.25, 3.75);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
new file mode 100644
index 00000000000..e16f02ea6db
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator/(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ T lhs(-8.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(-1.5, 2.5);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
new file mode 100644
index 00000000000..0cd903541fe
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator==(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert(!(lhs == rhs), "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert(lhs == rhs, "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 0);
+ assert(!(lhs == rhs));
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert(!(lhs == rhs));
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 0);
+ assert(lhs == rhs);
+ }
+
+ test_constexpr<T> ();
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
new file mode 100644
index 00000000000..35a3749118e
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(-2.0, -4.5);
+ test(lhs, rhs, x);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(5.0, -4.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
new file mode 100644
index 00000000000..7d6003cb891
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// bool
+// operator!=(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(-2.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 2.5);
+ static_assert (lhs != rhs, "");
+ }
+ {
+ constexpr T lhs(1.5);
+ constexpr std::complex<T> rhs(1.5, 0);
+ static_assert (!(lhs != rhs), "");
+ }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert (lhs != rhs);
+ }
+ {
+ T lhs(-2.5);
+ std::complex<T> rhs(1.5, 0);
+ assert (lhs != rhs);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 2.5);
+ assert (lhs != rhs);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 0);
+ assert (!(lhs != rhs));
+ }
+
+ test_constexpr<T> ();
+ }
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+// test_constexpr<int>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
new file mode 100644
index 00000000000..ec0de5a7f96
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(3.5, 4.5);
+ std::complex<T> x(5.0, 4.5);
+ test(lhs, rhs, x);
+ }
+ {
+ T lhs(1.5);
+ std::complex<T> rhs(-3.5, 4.5);
+ std::complex<T> x(-2.0, 4.5);
+ test(lhs, rhs, x);
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
new file mode 100644
index 00000000000..ebff8b23ba6
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator*(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+ assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+ T lhs(1.5);
+ std::complex<T> rhs(1.5, 2.5);
+ std::complex<T> x(2.25, 3.75);
+ test(lhs, rhs, x);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp
new file mode 100644
index 00000000000..24644e30779
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is, complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream is("5");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5, 0));
+ assert(is.eof());
+ }
+ {
+ std::istringstream is(" 5 ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" 5, ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" , 5, ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(0, 0));
+ assert(is.fail());
+ }
+ {
+ std::istringstream is("5.5 ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5.5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" ( 5.5 ) ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5.5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is(" 5.5)");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(5.5, 0));
+ assert(is.good());
+ }
+ {
+ std::istringstream is("(5.5 ");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(0, 0));
+ assert(is.fail());
+ }
+ {
+ std::istringstream is("(5.5,");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(0, 0));
+ assert(is.fail());
+ }
+ {
+ std::istringstream is("( -5.5 , -6.5 )");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(-5.5, -6.5));
+ assert(!is.eof());
+ }
+ {
+ std::istringstream is("(-5.5,-6.5)");
+ std::complex<double> c;
+ is >> c;
+ assert(c == std::complex<double>(-5.5, -6.5));
+ assert(!is.eof());
+ }
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp
new file mode 100644
index 00000000000..edb381cf60a
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::complex<double> c(1, 2);
+ std::ostringstream os;
+ os << c;
+ assert(os.str() == "(1,2)");
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp
new file mode 100644
index 00000000000..6a3a201ceaa
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator-(const complex<T>& lhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(z.real() == 1.5);
+ assert(z.imag() == 2.5);
+ std::complex<T> c = -z;
+ assert(c.real() == -1.5);
+ assert(c.imag() == -2.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp
new file mode 100644
index 00000000000..5edaad29e68
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// operator+(const complex<T>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(z.real() == 1.5);
+ assert(z.imag() == 2.5);
+ std::complex<T> c = +z;
+ assert(c.real() == 1.5);
+ assert(c.imag() == 2.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
new file mode 100644
index 00000000000..e8d07ce287d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
new file mode 100644
index 00000000000..298aaa3a7a8
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
new file mode 100644
index 00000000000..6ff74a2cdef
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp b/libcxx/test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
new file mode 100644
index 00000000000..3866f6e33e7
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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());
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
new file mode 100644
index 00000000000..77ca9d7f2aa
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp b/libcxx/test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
new file mode 100644
index 00000000000..d1519753285
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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());
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
new file mode 100644
index 00000000000..4fb11b4ca27
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp b/libcxx/test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
new file mode 100644
index 00000000000..9401febee5d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+// explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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());
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
new file mode 100644
index 00000000000..dd10c808b90
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
new file mode 100644
index 00000000000..aab539407d0
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
new file mode 100644
index 00000000000..a5f5101c4dc
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
new file mode 100644
index 00000000000..25b93823f6e
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+// constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+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/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
new file mode 100644
index 00000000000..f8ee306d754
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// acos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(acos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(INFINITY, 1), std::complex<T>(0, -INFINITY));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = acos(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ is_about(r.real(), pi/2);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ is_about(r.real(), pi/2);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ is_about(r.real(), pi/2);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && x[i].real() != 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ is_about(r.real(), pi);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+ {
+ is_about(r.real(), 0.75 * pi);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+ {
+ is_about(r.real(), 0.25 * pi);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (!std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert( std::signbit(r.imag()));
+ }
+ else if (std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert( std::signbit(r.imag()));
+ }
+ else if (std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert(!std::signbit(r.imag()));
+ }
+ else if (!std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert(!std::signbit(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
new file mode 100644
index 00000000000..88a5c798424
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// acosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(acosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(INFINITY, 1), std::complex<T>(INFINITY, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = acosh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(!std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (x[i].real() == 1 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -0.75 * pi);
+ else
+ is_about(r.imag(), 0.75 * pi);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -0.25 * pi);
+ else
+ is_about(r.imag(), 0.25 * pi);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
new file mode 100644
index 00000000000..c743be6488c
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// asin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(asin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = asin(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ if (x[i].real() > 0)
+ is_about(r.real(), pi/2);
+ else
+ is_about(r.real(), - pi/2);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ if (std::signbit(x[i].real()))
+ is_about(r.real(), -pi/4);
+ else
+ is_about(r.real(), pi/4);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].real()) != std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
new file mode 100644
index 00000000000..027bc6a98a9
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// asinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(asinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = asinh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/4);
+ else
+ is_about(r.imag(), pi/4);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp
new file mode 100644
index 00000000000..69bc9524014
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// atan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(atan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = atan(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> t2 = atanh(t1);
+ std::complex<double> z(imag(t2), -real(t2));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
new file mode 100644
index 00000000000..b821109b751
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// atanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(atanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = atanh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::abs(x[i].real()) == 1 && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (x[i].imag() > 0)
+ is_about(r.imag(), pi/2);
+ else
+ is_about(r.imag(), -pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi/2);
+ else
+ is_about(r.imag(), pi/2);
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else
+ {
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp
new file mode 100644
index 00000000000..f25c967cb1a
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// cos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(cos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = cos(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> z = cosh(t1);
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
new file mode 100644
index 00000000000..acf4746389c
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// cosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(cosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = cosh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ }
+ else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(!std::signbit(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(r.real()) == std::signbit(cos(x[i].imag())));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].real() * sin(x[i].imag())));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp
new file mode 100644
index 00000000000..e8b507572f1
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// exp(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(exp(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = exp(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 1.0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(r.imag() == 0);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(r.imag() == 0);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() != 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].imag()) && std::abs(x[i].imag()) <= 1)
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp
new file mode 100644
index 00000000000..800b92474bf
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// log(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(log(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = log(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ if (std::signbit(x[i].real()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() < 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
+ else
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() < 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ if (x[i].imag() > 0)
+ is_about(r.imag(), pi/2);
+ else
+ is_about(r.imag(), -pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()) && r.real() > 0);
+ if (r.imag() > 0)
+ is_about(r.imag(), pi);
+ else
+ is_about(r.imag(), -pi);
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()) && r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (x[i].real() == 1 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (x[i].real() == 0 && x[i].imag() == 1)
+ {
+ assert(r.real() == 0);
+ is_about(r.imag(), pi/2);
+ }
+ else if (x[i].real() == -1 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ if (std::signbit(x[i].imag()))
+ is_about(r.imag(), -pi);
+ else
+ is_about(r.imag(), pi);
+ }
+ else if (x[i].real() == 0 && x[i].imag() == -1)
+ {
+ assert(r.real() == 0);
+ is_about(r.imag(), -pi/2);
+ }
+ else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) < 1)
+ {
+ assert( std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) > 1)
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp
new file mode 100644
index 00000000000..ba03ebf8ad2
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// log10(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(log10(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = log10(x[i]);
+ std::complex<double> z = log(x[i])/std::log(10);
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
new file mode 100644
index 00000000000..258193d257a
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// pow(const complex<T>& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const std::complex<T>& b, std::complex<T> x)
+{
+ std::complex<T> c = pow(a, b);
+ is_about(real(c), real(x));
+ is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(2, 3), std::complex<T>(2, 0), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = pow(x[i], x[j]);
+ std::complex<double> z = exp(x[j] * log(x[i]));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
new file mode 100644
index 00000000000..03bd10d465d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// pow(const complex<T>& x, const T& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const T& b, std::complex<T> x)
+{
+ std::complex<T> c = pow(a, b);
+ is_about(real(c), real(x));
+ is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(2, 3), T(2), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = pow(x[i], real(x[j]));
+ std::complex<double> z = exp(std::complex<double>(real(x[j])) * log(x[i]));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
new file mode 100644
index 00000000000..a48498cea92
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// pow(const T& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& a, const std::complex<T>& b, std::complex<T> x)
+{
+ std::complex<T> c = pow(a, b);
+ is_about(real(c), real(x));
+ assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+ test(T(2), std::complex<T>(2), std::complex<T>(4));
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ for (unsigned j = 0; j < N; ++j)
+ {
+ std::complex<double> r = pow(real(x[i]), x[j]);
+ std::complex<double> z = exp(x[j] * log(std::complex<double>(real(x[i]))));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp
new file mode 100644
index 00000000000..068222a2737
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// sin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(sin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = sin(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> t2 = sinh(t1);
+ std::complex<double> z(imag(t2), -real(t2));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
new file mode 100644
index 00000000000..dcd30e48dff
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// sinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(sinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = sinh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::signbit(r.real()) == std::signbit(x[i].real() * cos(x[i].imag())));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(r.imag()) == std::signbit(sin(x[i].imag())));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
new file mode 100644
index 00000000000..69309d2b9ab
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// sqrt(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ std::complex<T> a = sqrt(c);
+ is_about(real(a), real(x));
+ assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(64, 0), std::complex<T>(8, 0));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = sqrt(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isinf(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 0);
+ assert(!std::signbit(r.real()));
+ assert(std::isinf(r.imag()));
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(r.imag() == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isinf(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+ {
+ assert(std::isinf(r.real()));
+ assert(r.real() > 0);
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && (std::isfinite(x[i].imag()) || std::isnan(x[i].imag())))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::signbit(x[i].imag()))
+ {
+ assert(!std::signbit(r.real()));
+ assert(std::signbit(r.imag()));
+ }
+ else
+ {
+ assert(!std::signbit(r.real()));
+ assert(!std::signbit(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp
new file mode 100644
index 00000000000..88142760068
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// tan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(tan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+ test(std::complex<T>(10000, -10000), std::complex<T>(0, -1));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = tan(x[i]);
+ std::complex<double> t1(-imag(x[i]), real(x[i]));
+ std::complex<double> t2 = tanh(t1);
+ std::complex<double> z(imag(t2), -real(t2));
+ if (std::isnan(real(r)))
+ assert(std::isnan(real(z)));
+ else
+ {
+ assert(real(r) == real(z));
+ assert(std::signbit(real(r)) == std::signbit(real(z)));
+ }
+ if (std::isnan(imag(r)))
+ assert(std::isnan(imag(z)));
+ else
+ {
+ assert(imag(r) == imag(z));
+ assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
new file mode 100644
index 00000000000..907c0e64dba
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// tanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+ assert(tanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+ typedef std::complex<double> C;
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = tanh(x[i]);
+ if (x[i].real() == 0 && x[i].imag() == 0)
+ {
+ assert(r.real() == 0);
+ assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(sin(2*x[i].imag())));
+ }
+ else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ }
+ else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(r.real() == 1);
+ assert(r.imag() == 0);
+ }
+ else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+ {
+ assert(std::isnan(r.real()));
+ assert(r.imag() == 0);
+ assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+ {
+ assert(std::isnan(r.real()));
+ assert(std::isnan(r.imag()));
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp
new file mode 100644
index 00000000000..5d841d6ee9f
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// abs(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(3, 4);
+ assert(abs(z) == 5);
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = abs(x[i]);
+ switch (classify(x[i]))
+ {
+ case zero:
+ assert(r == 0);
+ assert(!std::signbit(r));
+ break;
+ case non_zero:
+ assert(std::isfinite(r) && r > 0);
+ break;
+ case inf:
+ assert(std::isinf(r) && r > 0);
+ break;
+ case NaN:
+ assert(std::isnan(r));
+ break;
+ case non_zero_nan:
+ assert(std::isnan(r));
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp
new file mode 100644
index 00000000000..a7da456b979
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// arg(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1, 0);
+ assert(arg(z) == 0);
+}
+
+void test_edges()
+{
+ const double pi = std::atan2(+0., -0.);
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = arg(x[i]);
+ if (std::isnan(x[i].real()) || std::isnan(x[i].imag()))
+ assert(std::isnan(r));
+ else
+ {
+ switch (classify(x[i]))
+ {
+ case zero:
+ if (std::signbit(x[i].real()))
+ {
+ if (std::signbit(x[i].imag()))
+ is_about(r, -pi);
+ else
+ is_about(r, pi);
+ }
+ else
+ {
+ assert(std::signbit(x[i].imag()) == std::signbit(r));
+ }
+ break;
+ case non_zero:
+ if (x[i].real() == 0)
+ {
+ if (x[i].imag() < 0)
+ is_about(r, -pi/2);
+ else
+ is_about(r, pi/2);
+ }
+ else if (x[i].imag() == 0)
+ {
+ if (x[i].real() < 0)
+ {
+ if (std::signbit(x[i].imag()))
+ is_about(r, -pi);
+ else
+ is_about(r, pi);
+ }
+ else
+ {
+ assert(r == 0);
+ assert(std::signbit(x[i].imag()) == std::signbit(r));
+ }
+ }
+ else if (x[i].imag() > 0)
+ assert(r > 0);
+ else
+ assert(r < 0);
+ break;
+ case inf:
+ if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+ {
+ if (x[i].real() < 0)
+ {
+ if (x[i].imag() > 0)
+ is_about(r, 0.75 * pi);
+ else
+ is_about(r, -0.75 * pi);
+ }
+ else
+ {
+ if (x[i].imag() > 0)
+ is_about(r, 0.25 * pi);
+ else
+ is_about(r, -0.25 * pi);
+ }
+ }
+ else if (std::isinf(x[i].real()))
+ {
+ if (x[i].real() < 0)
+ {
+ if (std::signbit(x[i].imag()))
+ is_about(r, -pi);
+ else
+ is_about(r, pi);
+ }
+ else
+ {
+ assert(r == 0);
+ assert(std::signbit(r) == std::signbit(x[i].imag()));
+ }
+ }
+ else
+ {
+ if (x[i].imag() < 0)
+ is_about(r, -pi/2);
+ else
+ is_about(r, pi/2);
+ }
+ break;
+ }
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp
new file mode 100644
index 00000000000..71f276d8d47
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/conj.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// conj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+ assert(conj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(1, 2), std::complex<T>(1, -2));
+ test(std::complex<T>(-1, 2), std::complex<T>(-1, -2));
+ test(std::complex<T>(1, -2), std::complex<T>(1, 2));
+ test(std::complex<T>(-1, -2), std::complex<T>(-1, 2));
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp
new file mode 100644
index 00000000000..fa7b7339a6d
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/imag.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// imag(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(imag(z) == 2.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
new file mode 100644
index 00000000000..48f774e8e1c
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// norm(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(3, 4);
+ assert(norm(z) == 25);
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = norm(x[i]);
+ switch (classify(x[i]))
+ {
+ case zero:
+ assert(r == 0);
+ assert(!std::signbit(r));
+ break;
+ case non_zero:
+ assert(std::isfinite(r) && r > 0);
+ break;
+ case inf:
+ assert(std::isinf(r) && r > 0);
+ break;
+ case NaN:
+ assert(std::isnan(r));
+ break;
+ case non_zero_nan:
+ assert(std::isnan(r));
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp
new file mode 100644
index 00000000000..a8747bd7c83
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// polar(const T& rho, const T& theta = 0);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& rho, std::complex<T> x)
+{
+ assert(std::polar(rho) == x);
+}
+
+template <class T>
+void
+test(const T& rho, const T& theta, std::complex<T> x)
+{
+ assert(std::polar(rho, theta) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(T(0), std::complex<T>(0, 0));
+ test(T(1), std::complex<T>(1, 0));
+ test(T(100), std::complex<T>(100, 0));
+ test(T(0), T(0), std::complex<T>(0, 0));
+ test(T(1), T(0), std::complex<T>(1, 0));
+ test(T(100), T(0), std::complex<T>(100, 0));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ double r = real(x[i]);
+ double theta = imag(x[i]);
+ std::complex<double> z = std::polar(r, theta);
+ switch (classify(r))
+ {
+ case zero:
+ if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ else
+ {
+ assert(z == std::complex<double>());
+ }
+ break;
+ case non_zero:
+ if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ else
+ {
+ is_about(std::abs(z), r);
+ }
+ break;
+ case inf:
+ if (r < 0)
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ else
+ {
+ assert(classify(z) == inf);
+ if (classify(theta) != NaN && classify(theta) != inf)
+ {
+ assert(classify(real(z)) != NaN);
+ assert(classify(imag(z)) != NaN);
+ }
+ }
+ break;
+ case NaN:
+ case non_zero_nan:
+ {
+ int c = classify(z);
+ assert(c == NaN || c == non_zero_nan);
+ }
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
new file mode 100644
index 00000000000..10bf7f8576f
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// complex<T>
+// proj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+ assert(proj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+ test(std::complex<T>(1, 2), std::complex<T>(1, 2));
+ test(std::complex<T>(-1, 2), std::complex<T>(-1, 2));
+ test(std::complex<T>(1, -2), std::complex<T>(1, -2));
+ test(std::complex<T>(-1, -2), std::complex<T>(-1, -2));
+}
+
+void test_edges()
+{
+ const unsigned N = sizeof(x) / sizeof(x[0]);
+ for (unsigned i = 0; i < N; ++i)
+ {
+ std::complex<double> r = proj(x[i]);
+ switch (classify(x[i]))
+ {
+ case zero:
+ case non_zero:
+ assert(r == x[i]);
+ assert(std::signbit(real(r)) == std::signbit(real(x[i])));
+ assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+ break;
+ case inf:
+ assert(std::isinf(real(r)) && real(r) > 0);
+ assert(imag(r) == 0);
+ assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+ break;
+ case NaN:
+ case non_zero_nan:
+ assert(classify(r) == classify(x[i]));
+ break;
+ }
+ }
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+ test_edges();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp b/libcxx/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
new file mode 100644
index 00000000000..fbb51f08064
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex.value.ops/real.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// T
+// real(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z(1.5, 2.5);
+ assert(real(z) == 1.5);
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/complex/types.pass.cpp b/libcxx/test/std/numerics/complex.number/complex/types.pass.cpp
new file mode 100644
index 00000000000..4da9a2a9029
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/complex/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// class complex
+// {
+// public:
+// typedef T value_type;
+// ...
+// };
+
+#include <complex>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+ typedef std::complex<T> C;
+ static_assert((std::is_same<typename C::value_type, T>::value), "");
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/layout.pass.cpp b/libcxx/test/std/numerics/complex.number/layout.pass.cpp
new file mode 100644
index 00000000000..a9f356d4a40
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/layout.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z;
+ T* a = (T*)&z;
+ assert(0 == z.real());
+ assert(0 == z.imag());
+ assert(a[0] == z.real());
+ assert(a[1] == z.imag());
+ a[0] = 5;
+ a[1] = 6;
+ assert(a[0] == z.real());
+ assert(a[1] == z.imag());
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
diff --git a/libcxx/test/std/numerics/complex.number/version.pass.cpp b/libcxx/test/std/numerics/complex.number/version.pass.cpp
new file mode 100644
index 00000000000..316cfec739a
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud