summaryrefslogtreecommitdiff
path: root/test/std/numerics/complex.number/complex.ops
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/numerics/complex.number/complex.ops')
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp159
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp60
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp62
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp161
-rw-r--r--test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp81
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp49
-rw-r--r--test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp41
-rw-r--r--test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp99
-rw-r--r--test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp26
-rw-r--r--test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp36
-rw-r--r--test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp36
22 files changed, 1421 insertions, 0 deletions
diff --git a/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
new file mode 100644
index 0000000000000..86119678aa70e
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
new file mode 100644
index 0000000000000..b23b381cb59d4
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
new file mode 100644
index 0000000000000..970f021f8e63b
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
new file mode 100644
index 0000000000000..3c8b772bcaa5b
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
new file mode 100644
index 0000000000000..b2cddd26d8b5b
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
new file mode 100644
index 0000000000000..b630679fc9852
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
new file mode 100644
index 0000000000000..ee138c1ecbcde
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
new file mode 100644
index 0000000000000..efb1c0e872db7
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
new file mode 100644
index 0000000000000..02ed8684ea927
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
new file mode 100644
index 0000000000000..eeec83fb09ad5
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
new file mode 100644
index 0000000000000..565eaa5657cd1
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp b/test/std/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
new file mode 100644
index 0000000000000..0e829a4caa689
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
new file mode 100644
index 0000000000000..e16f02ea6db9b
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
new file mode 100644
index 0000000000000..0cd903541fe31
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
new file mode 100644
index 0000000000000..35a3749118e9f
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
new file mode 100644
index 0000000000000..7d6003cb891b4
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
new file mode 100644
index 0000000000000..ec0de5a7f9604
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp b/test/std/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
new file mode 100644
index 0000000000000..ebff8b23ba6ce
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp b/test/std/numerics/complex.number/complex.ops/stream_input.pass.cpp
new file mode 100644
index 0000000000000..24644e3077999
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp b/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp
new file mode 100644
index 0000000000000..edb381cf60abb
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp b/test/std/numerics/complex.number/complex.ops/unary_minus.pass.cpp
new file mode 100644
index 0000000000000..6a3a201ceaa81
--- /dev/null
+++ b/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/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp b/test/std/numerics/complex.number/complex.ops/unary_plus.pass.cpp
new file mode 100644
index 0000000000000..5edaad29e6826
--- /dev/null
+++ b/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>();
+}