Skip to content

Commit 308ef70

Browse files
committed
refac(collectives_test): enable selective testing
1 parent d93b54f commit 308ef70

File tree

2 files changed

+64
-46
lines changed

2 files changed

+64
-46
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
module user_defined_collectives_test_m
2+
use sourcery_m, only : co_all, test_t, test_result_t, test_description_t, test_description_substring, test_function_i, string_t
3+
implicit none
4+
5+
private
6+
public :: collectives_test_t
7+
8+
type, extends(test_t) :: collectives_test_t
9+
contains
10+
procedure, nopass :: subject
11+
procedure, nopass :: results
12+
end type
13+
14+
contains
15+
16+
pure function subject() result(specimen)
17+
character(len=:), allocatable :: specimen
18+
specimen = "The co_all subroutine"
19+
end function
20+
21+
function results() result(test_results)
22+
type(test_result_t), allocatable :: test_results(:)
23+
type(test_description_t), allocatable :: test_descriptions(:)
24+
25+
#ifndef __GFORTRAN__
26+
test_descriptions = [ &
27+
test_description_t &
28+
(string_t("setting all arguments to .true. when previously .true. on all images"), check_co_all_with_all_true), &
29+
test_description_t
30+
(string_t("setting all arguments to .false. when previously .false. on image 1"), check_co_all_with_one_false) &
31+
]
32+
#else
33+
! Work around missing Fortran 2008 feature: associating a procedure actual argument with a procedure pointer dummy argument:
34+
procedure(test_function_i), pointer :: check_co_all_true_ptr, check_co_all_one_false_ptr
35+
check_co_all_true_ptr => check_co_all_with_all_true
36+
check_co_all_one_false_ptr => check_co_all_with_one_false
37+
test_descriptions = [ &
38+
test_description_t &
39+
(string_t("setting all arguments to .true. when previously .true. on all images"), check_co_all_true_ptr), &
40+
test_description_t &
41+
(string_t("setting all arguments to .false. when previously .false. on image 1"), check_co_all_one_false_ptr) &
42+
]
43+
#endif
44+
test_descriptions = pack(test_descriptions, test_descriptions%contains_text(string_t(test_description_substring)))
45+
test_results = test_descriptions%run()
46+
end function
47+
48+
function check_co_all_with_all_true() result(test_passed)
49+
logical test_passed, all_true
50+
51+
all_true=.true.
52+
call co_all(all_true)
53+
test_passed = all_true
54+
end function
55+
56+
function check_co_all_with_one_false() result(test_passed)
57+
logical test_passed, all_true
58+
59+
all_true = merge(.false., .true., this_image()==1)
60+
call co_all(all_true)
61+
test_passed = .not. all_true
62+
end function
63+
64+
end module user_defined_collectives_test_m

test/user_defined_collectives_test.f90

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)