Skip to content

Commit

Permalink
Make promise function tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPinezhaninov committed Dec 24, 2023
1 parent ebb2df1 commit 7a96650
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 260 deletions.
23 changes: 19 additions & 4 deletions include/async_promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2086,10 +2086,25 @@ class promise


/**
* @brief Make promise with an function to be called.
* Return promise object with a result or an error.
* @param func - Function.
* @param args - Function arguments.
* @brief Make a promise object with an initial class method.
* @param method - Method for call.
* @param obj - Object containing the required method.
* @param args - Optional arguments.
* @return Promise object.
*/
template<typename Method, typename Class, typename... Args,
typename Result = typename std::result_of<Method(Class*, Args...)>::type,
typename = typename std::enable_if<internal::is_invocable<Method, Class, Args...>::value>::type>
static promise<Result> make_promise(Method&& method, Class* obj, Args&&... args)
{
return promise<Result>{std::forward<Method>(method), obj, std::forward<Args>(args)...};
}


/**
* @brief Make a promise object with an initial function.
* @param func - Function or class method for call.
* @param args - Optional arguments.
* @return Promise object.
*/
template<typename Func, typename... Args,
Expand Down
19 changes: 9 additions & 10 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,22 @@ set(SOURCES
src/all_settled.cpp
src/all.cpp
src/any.cpp
src/class_initial.cpp
src/class_then.cpp
src/fail.cpp
src/finally.cpp
src/func_initial.cpp
src/func_then.cpp
src/make_all_settled.cpp
src/make_all.cpp
src/make_any.cpp
src/make_race.cpp
src/make_rejected.cpp
src/make_resolved.cpp
src/initial.cpp
src/make_promise_all_settled.cpp
src/make_promise_all.cpp
src/make_promise_any.cpp
src/make_promise_race.cpp
src/make_promise.cpp
src/make_rejected_promise.cpp
src/make_resolved_promise.cpp
src/race.cpp
src/settled.cpp
src/smoke.cpp
src/test_funcs.cpp
src/test_struct.cpp
src/then.cpp
)

set(TARGET async_promise_tests)
Expand Down
96 changes: 0 additions & 96 deletions tests/src/func_initial.cpp

This file was deleted.

130 changes: 0 additions & 130 deletions tests/src/func_then.cpp

This file was deleted.

Loading

0 comments on commit 7a96650

Please sign in to comment.