diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-08-25 17:32:05 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-08-25 17:32:05 +0000 |
commit | dae3481b28ad0bedd4c5b98385af499cbbe2a10b (patch) | |
tree | bb682a9c2b54b54914a58fee5f42fc4c333026b9 /libcxx/test/thread | |
parent | f1f2133ac088f732be5850b5b53439c9356e1ff1 (diff) | |
download | bcm5719-llvm-dae3481b28ad0bedd4c5b98385af499cbbe2a10b.tar.gz bcm5719-llvm-dae3481b28ad0bedd4c5b98385af499cbbe2a10b.zip |
Getting started on <future>
llvm-svn: 112061
Diffstat (limited to 'libcxx/test/thread')
11 files changed, 285 insertions, 0 deletions
diff --git a/libcxx/test/thread/futures/futures.errors/default_error_condition.pass.cpp b/libcxx/test/thread/futures/futures.errors/default_error_condition.pass.cpp new file mode 100644 index 00000000000..b792a6601bd --- /dev/null +++ b/libcxx/test/thread/futures/futures.errors/default_error_condition.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// const error_category& future_category(); + +// virtual error_condition default_error_condition(int ev) const; + +#include <future> +#include <cassert> + +int main() +{ + const std::error_category& e_cat = std::future_category(); + std::error_condition e_cond = e_cat.default_error_condition(std::errc::not_a_directory); + assert(e_cond.category() == e_cat); + assert(e_cond.value() == std::errc::not_a_directory); +} diff --git a/libcxx/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp b/libcxx/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp new file mode 100644 index 00000000000..2c7aa89e35a --- /dev/null +++ b/libcxx/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// const error_category& future_category(); + +// virtual bool equivalent(const error_code& code, int condition) const; + +#include <future> +#include <cassert> + +int main() +{ + const std::error_category& e_cat = std::future_category(); + assert(e_cat.equivalent(std::error_code(5, e_cat), 5)); + assert(!e_cat.equivalent(std::error_code(5, e_cat), 6)); +} diff --git a/libcxx/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp b/libcxx/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp new file mode 100644 index 00000000000..b24a53c18e2 --- /dev/null +++ b/libcxx/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// const error_category& future_category(); + +// virtual bool equivalent(int code, const error_condition& condition) const; + +#include <future> +#include <cassert> + +int main() +{ + const std::error_category& e_cat = std::future_category(); + std::error_condition e_cond = e_cat.default_error_condition(5); + assert(e_cat.equivalent(5, e_cond)); + assert(!e_cat.equivalent(6, e_cond)); +} diff --git a/libcxx/test/thread/futures/futures.errors/future_category.pass.cpp b/libcxx/test/thread/futures/futures.errors/future_category.pass.cpp new file mode 100644 index 00000000000..56a29d62c51 --- /dev/null +++ b/libcxx/test/thread/futures/futures.errors/future_category.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// const error_category& future_category(); + +#include <future> +#include <cstring> +#include <cassert> + +int main() +{ + const std::error_category& ec = std::future_category(); + assert(std::strcmp(ec.name(), "future") == 0); +} diff --git a/libcxx/test/thread/futures/futures.errors/make_error_code.pass.cpp b/libcxx/test/thread/futures/futures.errors/make_error_code.pass.cpp new file mode 100644 index 00000000000..400905647be --- /dev/null +++ b/libcxx/test/thread/futures/futures.errors/make_error_code.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class error_code + +// error_code make_error_code(future_errc e); + +#include <future> +#include <cassert> + +int main() +{ + { + std::error_code ec = make_error_code(std::future_errc::broken_promise); + assert(ec.value() == static_cast<int>(std::future_errc::broken_promise)); + assert(ec.category() == std::future_category()); + } +} diff --git a/libcxx/test/thread/futures/futures.errors/make_error_condition.pass.cpp b/libcxx/test/thread/futures/futures.errors/make_error_condition.pass.cpp new file mode 100644 index 00000000000..6a9b554235b --- /dev/null +++ b/libcxx/test/thread/futures/futures.errors/make_error_condition.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class error_condition + +// error_condition make_error_condition(future_errc e); + +#include <future> +#include <cassert> + +int main() +{ + { + const std::error_condition ec1 = + std::make_error_condition(std::future_errc::future_already_retrieved); + assert(ec1.value() == + static_cast<int>(std::future_errc::future_already_retrieved)); + assert(ec1.category() == std::future_category()); + } +} diff --git a/libcxx/test/thread/futures/futures.future_error/code.pass.cpp b/libcxx/test/thread/futures/futures.future_error/code.pass.cpp new file mode 100644 index 00000000000..9b7407ae95b --- /dev/null +++ b/libcxx/test/thread/futures/futures.future_error/code.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class future_error + +// const error_code& code() const throw(); + +#include <future> +#include <cassert> + +int main() +{ + { + std::error_code ec = std::make_error_code(std::future_errc::broken_promise); + std::future_error f(ec); + assert(f.code() == ec); + } + { + std::error_code ec = std::make_error_code(std::future_errc::future_already_retrieved); + std::future_error f(ec); + assert(f.code() == ec); + } + { + std::error_code ec = std::make_error_code(std::future_errc::promise_already_satisfied); + std::future_error f(ec); + assert(f.code() == ec); + } + { + std::error_code ec = std::make_error_code(std::future_errc::no_state); + std::future_error f(ec); + assert(f.code() == ec); + } +} diff --git a/libcxx/test/thread/futures/futures.future_error/types.pass.cpp b/libcxx/test/thread/futures/futures.future_error/types.pass.cpp new file mode 100644 index 00000000000..9802051f366 --- /dev/null +++ b/libcxx/test/thread/futures/futures.future_error/types.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class future_error : public logic_error {...}; + +#include <future> +#include <type_traits> + +int main() +{ + static_assert((std::is_convertible<std::future_error*, + std::logic_error*>::value), ""); +} diff --git a/libcxx/test/thread/futures/futures.future_error/what.pass.cpp b/libcxx/test/thread/futures/futures.future_error/what.pass.cpp new file mode 100644 index 00000000000..082308da820 --- /dev/null +++ b/libcxx/test/thread/futures/futures.future_error/what.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// class future_error + +// const char* what() const throw(); + +#include <future> +#include <cstring> +#include <cassert> + +int main() +{ + { + std::future_error f(std::make_error_code(std::future_errc::broken_promise)); + assert(std::strcmp(f.what(), "The associated promise has been destructed prior " + "to the associated state becoming ready.") == 0); + } + { + std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved)); + assert(std::strcmp(f.what(), "The future has already been retrieved from " + "the promise or packaged_task.") == 0); + } + { + std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied)); + assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0); + } + { + std::future_error f(std::make_error_code(std::future_errc::no_state)); + assert(std::strcmp(f.what(), "Operation not permitted on an object without " + "an associated state.") == 0); + } +} diff --git a/libcxx/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp b/libcxx/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp new file mode 100644 index 00000000000..ba5f6e7c9c5 --- /dev/null +++ b/libcxx/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <future> + +// template <> struct is_error_code_enum<future_errc> : public true_type {}; + +#include <future> + +int main() +{ + static_assert(std::is_error_code_enum<std::future_errc>::value, ""); +} diff --git a/libcxx/test/thread/futures/futures.state/nothing_to_do.pass.cpp b/libcxx/test/thread/futures/futures.state/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b85601fc46f --- /dev/null +++ b/libcxx/test/thread/futures/futures.state/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- C++ -*- +//===-------------------------- algorithm ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} |