|
1 | 1 | module user_defined_collectives_test |
2 | | - use Vegetables, only: Result_t, Test_Item_t, describe, it, assert_equals, assert_that, assert_not |
3 | 2 | use user_defined_collectives_m, only : co_all |
| 3 | + use test_m, only : test_t, test_result_t |
4 | 4 | implicit none |
5 | 5 |
|
6 | 6 | private |
7 | | - public :: test_co_all |
| 7 | + public :: collectives_test_t |
| 8 | + |
| 9 | + type, extends(test_t) :: collectives_test_t |
| 10 | + contains |
| 11 | + procedure, nopass :: subject |
| 12 | + procedure, nopass :: results |
| 13 | + end type |
8 | 14 |
|
9 | 15 | contains |
10 | 16 |
|
11 | | - function test_co_all() result(tests) |
12 | | - type(Test_Item_t) :: tests |
13 | | - |
14 | | - tests = describe( & |
15 | | - "co_all", & |
16 | | - [it( & |
17 | | - "sets all arguments to .true. when previously .true. on all images", & |
18 | | - check_co_all_with_all_true), & |
19 | | - it( & |
20 | | - "sets all arguments to .false. when previously .false. on image 1", & |
21 | | - check_co_all_with_one_false)]) |
22 | | - end function |
23 | | - |
24 | | - function check_co_all_with_all_true() result(result_) |
25 | | - type(Result_t) :: result_ |
26 | | - logical all_true |
27 | | - |
28 | | - all_true=.true. |
29 | | - |
30 | | - call co_all(all_true) |
31 | | - result_ = assert_that(all_true, "co_all argument remains .true. after call with all arguments .true.") |
32 | | - end function |
33 | | - |
34 | | - function check_co_all_with_one_false() result(result_) |
35 | | - type(Result_t) :: result_ |
36 | | - logical all_true |
37 | | - |
38 | | - all_true = merge(.false., .true., this_image()==1) |
39 | | - call co_all(all_true) |
40 | | - result_ = assert_not(all_true, "co_all argument is .false. after call with one argument .false.") |
41 | | - end function |
| 17 | + pure function subject() result(specimen) |
| 18 | + character(len=:), allocatable :: specimen |
| 19 | + specimen = "The co_all subroutine" |
| 20 | + end function |
| 21 | + |
| 22 | + function results() result(test_results) |
| 23 | + type(test_result_t), allocatable :: test_results(:) |
| 24 | + |
| 25 | + test_results = [ & |
| 26 | + test_result_t("setting all arguments to .true. when previously .true. on all images", check_co_all_with_all_true()), & |
| 27 | + test_result_t("setting all arguments to .false. when previously .false. on image 1", check_co_all_with_one_false()) & |
| 28 | + ] |
| 29 | + end function |
| 30 | + |
| 31 | + function check_co_all_with_all_true() result(test_passed) |
| 32 | + logical test_passed, all_true |
| 33 | + |
| 34 | + all_true=.true. |
| 35 | + call co_all(all_true) |
| 36 | + test_passed = all_true |
| 37 | + end function |
| 38 | + |
| 39 | + function check_co_all_with_one_false() result(test_passed) |
| 40 | + logical test_passed, all_true |
| 41 | + |
| 42 | + all_true = merge(.false., .true., this_image()==1) |
| 43 | + call co_all(all_true) |
| 44 | + test_passed = .not. all_true |
| 45 | + end function |
42 | 46 |
|
43 | 47 | end module user_defined_collectives_test |
0 commit comments