Author: ericwf Date: Wed Jun 1 16:05:53 2016 New Revision: 271430 URL: http://llvm.org/viewvc/llvm-project?rev=271430&view=rev Log: Cleanup non-standard tests as reported by s...@microsoft.com. NFC.
This patch addresses the following issues in the test suite: 1. Move "std::bad_array_length" test from std/ to libcxx/ test directory since the feature is not a part of the standard. 2. Rename "futures.tas" test directory to "futures.task" since that is the correct stable name. 3. Move tests for "packaged_task<T>::result_type" from std/ to libcxx/ test directory since the typedef is a libc++ extension. Added: libcxx/trunk/test/libcxx/language.support/ libcxx/trunk/test/libcxx/language.support/support.dynamic/ libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/ libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/ libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp libcxx/trunk/test/libcxx/thread/futures/futures.task/ libcxx/trunk/test/libcxx/thread/futures/futures.task/types.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_copy.fail.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_move.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_copy.fail.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_default.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_move.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/swap.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/swap.pass.cpp libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp Removed: libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp libcxx/trunk/test/std/thread/futures/futures.tas/ Modified: libcxx/trunk/include/future Modified: libcxx/trunk/include/future URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=271430&r1=271429&r2=271430&view=diff ============================================================================== --- libcxx/trunk/include/future (original) +++ libcxx/trunk/include/future Wed Jun 1 16:05:53 2016 @@ -322,7 +322,7 @@ template <class R, class... ArgTypes> class packaged_task<R(ArgTypes...)> { public: - typedef R result_type; + typedef R result_type; // extension // construction and destruction packaged_task() noexcept; @@ -1998,7 +1998,7 @@ template<class _Rp, class ..._ArgTypes> class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)> { public: - typedef _Rp result_type; + typedef _Rp result_type; // extension private: __packaged_task_function<result_type(_ArgTypes...)> __f_; @@ -2127,7 +2127,7 @@ template<class ..._ArgTypes> class _LIBCPP_TYPE_VIS_ONLY packaged_task<void(_ArgTypes...)> { public: - typedef void result_type; + typedef void result_type; // extension private: __packaged_task_function<result_type(_ArgTypes...)> __f_; Added: libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp (added) +++ libcxx/trunk/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 +// test bad_array_length + +#include <new> +#include <type_traits> +#include <cassert> + +int main() +{ + static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value), + "std::is_base_of<std::bad_alloc, std::bad_array_length>::value"); + static_assert(std::is_polymorphic<std::bad_array_length>::value, + "std::is_polymorphic<std::bad_array_length>::value"); + std::bad_array_length b; + std::bad_array_length b2 = b; + b2 = b; + const char* w = b2.what(); + assert(w); +} Added: libcxx/trunk/test/libcxx/thread/futures/futures.task/types.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/futures/futures.task/types.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/libcxx/thread/futures/futures.task/types.pass.cpp (added) +++ libcxx/trunk/test/libcxx/thread/futures/futures.task/types.pass.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// template<class R, class... ArgTypes> +// class packaged_task<R(ArgTypes...)> +// { +// public: +// typedef R result_type; // extension + +// This is a libc++ extension. + +#include <future> +#include <type_traits> + +struct A {}; + +int main() +{ + static_assert((std::is_same<std::packaged_task<A(int, char)>::result_type, A>::value), ""); +} Removed: libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp?rev=271429&view=auto ============================================================================== --- libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp (removed) @@ -1,28 +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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// test bad_array_length - -#include <new> -#include <type_traits> -#include <cassert> - -int main() -{ - static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value), - "std::is_base_of<std::bad_alloc, std::bad_array_length>::value"); - static_assert(std::is_polymorphic<std::bad_array_length>::value, - "std::is_polymorphic<std::bad_array_length>::value"); - std::bad_array_length b; - std::bad_array_length b2 = b; - b2 = b; - const char* w = b2.what(); - assert(w); -} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_copy.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_copy.fail.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_copy.fail.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_copy.fail.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// packaged_task& operator=(packaged_task&) = delete; + +#include <future> + +int main() +{ + { + std::packaged_task<double(int, char)> p0, p; + p = p0; // expected-error {{overload resolution selected deleted operator '='}} + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_move.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_move.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/assign_move.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// packaged_task& operator=(packaged_task&& other); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int main() +{ + { + std::packaged_task<double(int, char)> p0(A(5)); + std::packaged_task<double(int, char)> p; + p = std::move(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p0; + std::packaged_task<double(int, char)> p; + p = std::move(p0); + assert(!p0.valid()); + assert(!p.valid()); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> +// template <class F> +// packaged_task(F&& f); +// These constructors shall not participate in overload resolution if +// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>. + +#include <future> +#include <cassert> + +struct A {}; +typedef std::packaged_task<A(int, char)> PT; +typedef volatile std::packaged_task<A(int, char)> VPT; + + +int main() +{ + PT p { VPT{} }; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}} + // expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}} +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> +// template <class F, class Allocator> +// packaged_task(allocator_arg_t, const Allocator& a, F&& f); +// These constructors shall not participate in overload resolution if +// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>. + +#include <future> +#include <cassert> + +#include "test_allocator.h" + +struct A {}; +typedef std::packaged_task<A(int, char)> PT; +typedef volatile std::packaged_task<A(int, char)> VPT; + +int main() +{ + PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}} + // expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}} +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_copy.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_copy.fail.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_copy.fail.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_copy.fail.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// packaged_task(packaged_task&) = delete; + +#include <future> + + +int main() +{ + { + std::packaged_task<double(int, char)> p0; + std::packaged_task<double(int, char)> p(p0); // expected-error {{call to deleted constructor of 'std::packaged_task<double (int, char)>'}} + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_default.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_default.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_default.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_default.pass.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// packaged_task(); + +#include <future> +#include <cassert> + +struct A {}; + +int main() +{ + std::packaged_task<A(int, char)> p; + assert(!p.valid()); +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func.pass.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// template <class F> +// explicit packaged_task(F&& f); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + static int n_moves; + static int n_copies; + + explicit A(long i) : data_(i) {} + A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;} + A(const A& a) : data_(a.data_) {++n_copies;} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int A::n_moves = 0; +int A::n_copies = 0; + +int func(int i) { return i; } + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + assert(A::n_copies == 0); + assert(A::n_moves > 0); + } + A::n_copies = 0; + A::n_copies = 0; + { + A a(5); + std::packaged_task<double(int, char)> p(a); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + assert(A::n_copies > 0); + assert(A::n_moves > 0); + } + { + std::packaged_task<int(int)> p(&func); + assert(p.valid()); + std::future<int> f = p.get_future(); + p(4); + assert(f.get() == 4); + } + { + std::packaged_task<int(int)> p(func); + assert(p.valid()); + std::future<int> f = p.get_future(); + p(4); + assert(f.get() == 4); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,125 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// template <class F, class Allocator> +// explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); + +#include <future> +#include <cassert> + +#include "test_allocator.h" +#include "min_allocator.h" + +class A +{ + long data_; + +public: + static int n_moves; + static int n_copies; + + explicit A(long i) : data_(i) {} + A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;} + A(const A& a) : data_(a.data_) {++n_copies;} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int A::n_moves = 0; +int A::n_copies = 0; + +int func(int i) { return i; } + +int main() +{ + { + std::packaged_task<double(int, char)> p(std::allocator_arg, + test_allocator<A>(), A(5)); + assert(test_alloc_base::alloc_count > 0); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + assert(A::n_copies == 0); + assert(A::n_moves > 0); + } + assert(test_alloc_base::alloc_count == 0); + A::n_copies = 0; + A::n_moves = 0; + { + A a(5); + std::packaged_task<double(int, char)> p(std::allocator_arg, + test_allocator<A>(), a); + assert(test_alloc_base::alloc_count > 0); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + assert(A::n_copies > 0); + assert(A::n_moves > 0); + } + assert(test_alloc_base::alloc_count == 0); + A::n_copies = 0; + A::n_moves = 0; + { + A a(5); + std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), &func); + assert(test_alloc_base::alloc_count > 0); + assert(p.valid()); + std::future<int> f = p.get_future(); + p(4); + assert(f.get() == 4); + } + assert(test_alloc_base::alloc_count == 0); + A::n_copies = 0; + A::n_moves = 0; + { + A a(5); + std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), func); + assert(test_alloc_base::alloc_count > 0); + assert(p.valid()); + std::future<int> f = p.get_future(); + p(4); + assert(f.get() == 4); + } + assert(test_alloc_base::alloc_count == 0); + A::n_copies = 0; + A::n_moves = 0; + { + std::packaged_task<double(int, char)> p(std::allocator_arg, + bare_allocator<void>(), A(5)); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + assert(A::n_copies == 0); + assert(A::n_moves > 0); + } + A::n_copies = 0; + A::n_moves = 0; + { + std::packaged_task<double(int, char)> p(std::allocator_arg, + min_allocator<void>(), A(5)); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + assert(A::n_copies == 0); + assert(A::n_moves > 0); + } + A::n_copies = 0; + A::n_moves = 0; +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_move.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_move.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_move.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// packaged_task(packaged_task&& other); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int main() +{ + { + std::packaged_task<double(int, char)> p0(A(5)); + std::packaged_task<double(int, char)> p = std::move(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p0; + std::packaged_task<double(int, char)> p = std::move(p0); + assert(!p0.valid()); + assert(!p.valid()); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// ~packaged_task(); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +void func(std::packaged_task<double(int, char)> p) +{ +} + +void func2(std::packaged_task<double(int, char)> p) +{ + p(3, 'a'); +} + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func, std::move(p)).detach(); + try + { + double i = f.get(); + assert(false); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::broken_promise)); + } + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func2, std::move(p)).detach(); + assert(f.get() == 105.0); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// future<R> get_future(); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + try + { + f = p.get_future(); + assert(false); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::future_already_retrieved)); + } + } + { + std::packaged_task<double(int, char)> p; + try + { + std::future<double> f = p.get_future(); + assert(false); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::no_state)); + } + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp Wed Jun 1 16:05:53 2016 @@ -0,0 +1,108 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// void make_ready_at_thread_exit(ArgTypes... args); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const + { + if (j == 'z') + throw A(6); + return data_ + i + j; + } +}; + +void func0(std::packaged_task<double(int, char)> p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.make_ready_at_thread_exit(3, 'a'); +} + +void func1(std::packaged_task<double(int, char)> p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p.make_ready_at_thread_exit(3, 'z'); +} + +void func2(std::packaged_task<double(int, char)> p) +{ + p.make_ready_at_thread_exit(3, 'a'); + try + { + p.make_ready_at_thread_exit(3, 'c'); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); + } +} + +void func3(std::packaged_task<double(int, char)> p) +{ + try + { + p.make_ready_at_thread_exit(3, 'a'); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::no_state)); + } +} + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func0, std::move(p)).detach(); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func1, std::move(p)).detach(); + try + { + f.get(); + assert(false); + } + catch (const A& e) + { + assert(e(3, 'a') == 106); + } + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func2, std::move(p)).detach(); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p; + std::thread t(func3, std::move(p)); + t.join(); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// void operator()(ArgTypes... args); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const + { + if (j == 'z') + throw A(6); + return data_ + i + j; + } +}; + +void func0(std::packaged_task<double(int, char)> p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p(3, 'a'); +} + +void func1(std::packaged_task<double(int, char)> p) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + p(3, 'z'); +} + +void func2(std::packaged_task<double(int, char)> p) +{ + p(3, 'a'); + try + { + p(3, 'c'); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied)); + } +} + +void func3(std::packaged_task<double(int, char)> p) +{ + try + { + p(3, 'a'); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::no_state)); + } +} + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func0, std::move(p)).detach(); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func1, std::move(p)).detach(); + try + { + f.get(); + assert(false); + } + catch (const A& e) + { + assert(e(3, 'a') == 106); + } + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread t(func2, std::move(p)); + assert(f.get() == 105.0); + t.join(); + } + { + std::packaged_task<double(int, char)> p; + std::thread t(func3, std::move(p)); + t.join(); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// void reset(); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const + { + if (j == 'z') + throw A(6); + return data_ + i + j; + } +}; + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + p.reset(); + p(4, 'a'); + f = p.get_future(); + assert(f.get() == 106.0); + } + { + std::packaged_task<double(int, char)> p; + try + { + p.reset(); + assert(false); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::no_state)); + } + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/swap.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/swap.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/swap.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/swap.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// void swap(packaged_task& other); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int main() +{ + { + std::packaged_task<double(int, char)> p0(A(5)); + std::packaged_task<double(int, char)> p; + p.swap(p0); + assert(!p0.valid()); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p0; + std::packaged_task<double(int, char)> p; + p.swap(p0); + assert(!p0.valid()); + assert(!p.valid()); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/swap.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/swap.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/swap.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/swap.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// template <class R, class... ArgTypes> +// void +// swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +int main() +{ + { + std::packaged_task<double(int, char)> p0(A(5)); + std::packaged_task<double(int, char)> p; + swap(p, p0); + assert(!p0.valid()); + assert(p.valid()); + std::future<double> f = p.get_future(); + p(3, 'a'); + assert(f.get() == 105.0); + } + { + std::packaged_task<double(int, char)> p0; + std::packaged_task<double(int, char)> p; + swap(p, p0); + assert(!p0.valid()); + assert(!p.valid()); + } +} Added: libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp?rev=271430&view=auto ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp (added) +++ libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp Wed Jun 1 16:05:53 2016 @@ -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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// This test is marked XFAIL and not UNSUPPORTED because the non-variadic +// declaration of packaged_task is available in C++03. Therefore the test +// should fail because the static_assert fires and not because std::packaged_task +// in undefined. +// XFAIL: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// template <class Callable, class Alloc> +// struct uses_allocator<packaged_task<Callable>, Alloc> +// : true_type { }; + +#include <future> +#include "test_allocator.h" + +int main() +{ + static_assert((std::uses_allocator<std::packaged_task<double(int, char)>, test_allocator<int> >::value), ""); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits