| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <libdex.h> |
| 24 |
|
| 25 |
G_BEGIN_DECLS |
| 26 |
|
| 27 |
static inline DexFuture * |
| 28 |
_dex_test_runner_fiber (gpointer user_data) |
| 29 |
{ |
| 30 |
GTestFunc func = (GTestFunc) G_CALLBACK (user_data); |
| 31 |
|
| 32 |
func (); |
| 33 |
return dex_future_new_true (); |
| 34 |
} |
| 35 |
|
| 36 |
static inline DexFuture * |
| 37 |
_dex_test_runner_quit (DexFuture *future, |
| 38 |
gpointer user_data) |
| 39 |
{ |
| 40 |
g_main_loop_quit (user_data); |
| 41 |
return dex_ref (future); |
| 42 |
} |
| 43 |
|
| 44 |
static inline void |
| 45 |
_dex_test_runner (gconstpointer user_data) |
| 46 |
{ |
| 47 |
GMainLoop *main_loop = g_main_loop_new (NULL, FALSE); |
| 48 |
|
| 49 |
dex_init (); |
| 50 |
|
| 51 |
dex_future_disown (dex_future_finally (dex_scheduler_spawn (NULL, |
| 52 |
8 * 1024 * 1024, |
| 53 |
_dex_test_runner_fiber, |
| 54 |
(gpointer) user_data, |
| 55 |
NULL), |
| 56 |
_dex_test_runner_quit, |
| 57 |
g_main_loop_ref (main_loop), |
| 58 |
(GDestroyNotify) g_main_loop_unref)); |
| 59 |
|
| 60 |
g_main_loop_run (main_loop); |
| 61 |
g_main_loop_unref (main_loop); |
| 62 |
} |
| 63 |
|
| 64 |
static inline void |
| 65 |
_g_test_add_func (const char *path, |
| 66 |
GTestFunc test_func) |
| 67 |
{ |
| 68 |
g_test_add_data_func (path, test_func, _dex_test_runner); |
| 69 |
} |
| 70 |
|
| 71 |
G_END_DECLS |