diff options
Diffstat (limited to 'libcxx/test/experimental/optional/optional.object/optional.object.observe')
10 files changed, 0 insertions, 561 deletions
diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp deleted file mode 100644 index a3724375cf4..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/bool.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// constexpr explicit optional<T>::operator bool() const noexcept; - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -int main() -{ -#if _LIBCPP_STD_VER > 11 - using std::experimental::optional; - - { - constexpr optional<int> opt; - static_assert(!opt, ""); - } - { - constexpr optional<int> opt(0); - static_assert(opt, ""); - } -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp deleted file mode 100644 index 98e5dac9719..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/dereference.pass.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// T& optional<T>::operator*(); - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; - -struct X -{ - constexpr int test() const {return 3;} - int test() {return 4;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - optional<X> opt(X{}); - assert((*opt).test() == 4); - } -#ifdef _LIBCPP_DEBUG - { - optional<X> opt; - assert((*opt).test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp deleted file mode 100644 index c72a57852a3..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/dereference_const.pass.cpp +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// constexpr const T& optional<T>::operator*() const; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; - -struct X -{ - constexpr int test() const {return 3;} -}; - -struct Y -{ - int test() const {return 2;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - constexpr optional<X> opt(X{}); - static_assert((*opt).test() == 3, ""); - } - { - constexpr optional<Y> opt(Y{}); - assert((*opt).test() == 2); - } -#ifdef _LIBCPP_DEBUG - { - const optional<X> opt; - assert((*opt).test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp deleted file mode 100644 index e54a224d95b..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/op_arrow.pass.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// constexpr T* optional<T>::operator->(); - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; - -struct X -{ -#if _LIBCPP_STD_VER > 14 - constexpr int test() const {return 3;} -#else - constexpr int test() {return 3;} -#endif -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - constexpr optional<X> opt(X{}); - static_assert(opt->test() == 3, ""); - } -#ifdef _LIBCPP_DEBUG - { - optional<X> opt; - assert(opt->test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp deleted file mode 100644 index e813dd992a5..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// constexpr const T* optional<T>::operator->() const; - -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; - -struct X -{ - constexpr int test() const {return 3;} -}; - -struct Y -{ - int test() const {return 2;} -}; - -struct Z -{ - const Z* operator&() const {return this;} - constexpr int test() const {return 1;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - constexpr optional<X> opt(X{}); - static_assert(opt->test() == 3, ""); - } - { - constexpr optional<Y> opt(Y{}); - assert(opt->test() == 2); - } - { - constexpr optional<Z> opt(Z{}); - assert(opt->test() == 1); - } -#ifdef _LIBCPP_DEBUG - { - const optional<X> opt; - assert(opt->test() == 3); - assert(false); - } -#endif // _LIBCPP_DEBUG -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/value.pass.cpp deleted file mode 100644 index e91805e9c8e..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value.pass.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// T& optional<T>::value(); - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; -using std::experimental::bad_optional_access; - -struct X -{ - X() = default; - X(const X&) = delete; - constexpr int test() const {return 3;} - int test() {return 4;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - optional<X> opt; - opt.emplace(); - assert(opt.value().test() == 4); - } - { - optional<X> opt; - try - { - opt.value(); - assert(false); - } - catch (const bad_optional_access&) - { - } - } -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp deleted file mode 100644 index f0f8af6da45..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_const.fail.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// constexpr const T& optional<T>::value() const; - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; - -struct X -{ - constexpr int test() const {return 3;} - int test() {return 4;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - constexpr optional<X> opt; - static_assert(opt.value().test() == 3, ""); - } -#else -#error -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp deleted file mode 100644 index 39bf687ff3c..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// constexpr const T& optional<T>::value() const; - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; -using std::experimental::in_place_t; -using std::experimental::in_place; -using std::experimental::bad_optional_access; - -struct X -{ - X() = default; - X(const X&) = delete; - constexpr int test() const {return 3;} - int test() {return 4;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - constexpr optional<X> opt(in_place); - static_assert(opt.value().test() == 3, ""); - } - { - const optional<X> opt(in_place); - assert(opt.value().test() == 3); - } - { - const optional<X> opt; - try - { - opt.value(); - assert(false); - } - catch (const bad_optional_access&) - { - } - } -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp deleted file mode 100644 index 6118c44bb5b..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_or.pass.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// template <class U> T optional<T>::value_or(U&& v) &&; - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; -using std::experimental::in_place_t; -using std::experimental::in_place; - -struct Y -{ - int i_; - - Y(int i) : i_(i) {} -}; - -struct X -{ - int i_; - - X(int i) : i_(i) {} - X(X&& x) : i_(x.i_) {x.i_ = 0;} - X(const Y& y) : i_(y.i_) {} - X(Y&& y) : i_(y.i_+1) {} - friend constexpr bool operator==(const X& x, const X& y) - {return x.i_ == y.i_;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - optional<X> opt(in_place, 2); - Y y(3); - assert(std::move(opt).value_or(y) == 2); - assert(*opt == 0); - } - { - optional<X> opt(in_place, 2); - assert(std::move(opt).value_or(Y(3)) == 2); - assert(*opt == 0); - } - { - optional<X> opt; - Y y(3); - assert(std::move(opt).value_or(y) == 3); - assert(!opt); - } - { - optional<X> opt; - assert(std::move(opt).value_or(Y(3)) == 4); - assert(!opt); - } -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp b/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp deleted file mode 100644 index d51f18abbd2..00000000000 --- a/libcxx/test/experimental/optional/optional.object/optional.object.observe/value_or_const.pass.cpp +++ /dev/null @@ -1,82 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// <optional> - -// template <class U> constexpr T optional<T>::value_or(U&& v) const&; - -#include <experimental/optional> -#include <type_traits> -#include <cassert> - -#if _LIBCPP_STD_VER > 11 - -using std::experimental::optional; - -struct Y -{ - int i_; - - constexpr Y(int i) : i_(i) {} -}; - -struct X -{ - int i_; - - constexpr X(int i) : i_(i) {} - constexpr X(const Y& y) : i_(y.i_) {} - constexpr X(Y&& y) : i_(y.i_+1) {} - friend constexpr bool operator==(const X& x, const X& y) - {return x.i_ == y.i_;} -}; - -#endif // _LIBCPP_STD_VER > 11 - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - constexpr optional<X> opt(2); - constexpr Y y(3); - static_assert(opt.value_or(y) == 2, ""); - } - { - constexpr optional<X> opt(2); - static_assert(opt.value_or(Y(3)) == 2, ""); - } - { - constexpr optional<X> opt; - constexpr Y y(3); - static_assert(opt.value_or(y) == 3, ""); - } - { - constexpr optional<X> opt; - static_assert(opt.value_or(Y(3)) == 4, ""); - } - { - const optional<X> opt(2); - const Y y(3); - assert(opt.value_or(y) == 2); - } - { - const optional<X> opt(2); - assert(opt.value_or(Y(3)) == 2); - } - { - const optional<X> opt; - const Y y(3); - assert(opt.value_or(y) == 3); - } - { - const optional<X> opt; - assert(opt.value_or(Y(3)) == 4); - } -#endif // _LIBCPP_STD_VER > 11 -} |