Skip to content

Commit 5232cd6

Browse files
author
Damian Rouson
authored
Merge pull request #8 from sourceryinstitute/c-preprocessor
fix(tests): use supported intrinsic procedures
2 parents dc00785 + 66a81d1 commit 5232cd6

File tree

3 files changed

+48
-37
lines changed

3 files changed

+48
-37
lines changed

src/emulated_intrinsics_interface.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
module emulated_intrinsics_interface
88
!! author: Damian Rouson
99
!!
10-
!! Emulations of some Fortran 2008 and 2018 instrinsic procedures for use with
11-
!! compilers that lack support for the corresponding procedures.
10+
!! This module contains two categories of procedures:
11+
!! 1. Emulations of some Fortran 2008 and 2018 instrinsic procedures for use with
12+
!! compilers that lack support for the corresponding procedures.
13+
!! 2. User-defined collective procedures not defined in the Fortran standard.
1214
implicit none
1315

1416
interface
Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
module collective_subroutines_test
2-
use Vegetables, only: Result_t, Test_Item_t, describe, it, succeed, assert_equals, assert_that, assert_not
3-
use emulated_intrinsics_interface, only : co_sum, co_all
2+
use Vegetables, only: Result_t, Test_Item_t, describe, it, assert_equals, assert_that, assert_not
3+
use emulated_intrinsics_interface, only : &
4+
#ifdef COMPILER_LACKS_COLLECTIVE_SUBROUTINES
5+
co_all, co_sum
6+
#else
7+
co_all
8+
#endif
49

510
implicit none
611
private
712

8-
public :: test_co_sum, test_co_all
9-
contains
10-
function test_co_sum() result(tests)
11-
type(Test_Item_t) :: tests
13+
public :: test_co_all
14+
public :: test_co_sum
1215

13-
tests = describe( &
14-
"co_sum", &
15-
[it( &
16-
"gives sums with result_image present", &
17-
check_co_sum_with_result_image), &
18-
it( &
19-
"gives sums without result_image present", &
20-
check_co_sum_without_result_image)])
21-
end function
16+
contains
2217

2318
function test_co_all() result(tests)
2419
type(Test_Item_t) :: tests
@@ -33,6 +28,38 @@ function test_co_all() result(tests)
3328
check_co_all_with_one_false)])
3429
end function
3530

31+
function check_co_all_with_all_true() result(result_)
32+
type(Result_t) :: result_
33+
logical all_true
34+
35+
all_true=.true.
36+
37+
call co_all(all_true)
38+
result_ = assert_that(all_true, "co_all argument remains .true. after call with all arguments .true.")
39+
end function
40+
41+
function check_co_all_with_one_false() result(result_)
42+
type(Result_t) :: result_
43+
logical all_true
44+
45+
all_true = merge(.false., .true., this_image()==1)
46+
call co_all(all_true)
47+
result_ = assert_not(all_true, "co_all argument is .false. after call with one argument .false.")
48+
end function
49+
50+
function test_co_sum() result(tests)
51+
type(Test_Item_t) :: tests
52+
53+
tests = describe( &
54+
"co_sum", &
55+
[it( &
56+
"gives sums with result_image present", &
57+
check_co_sum_with_result_image), &
58+
it( &
59+
"gives sums without result_image present", &
60+
check_co_sum_without_result_image)])
61+
end function
62+
3663
function check_co_sum_with_result_image() result(result_)
3764
type(Result_t) :: result_
3865

@@ -63,23 +90,4 @@ function check_co_sum_without_result_image() result(result_)
6390
end associate
6491
end function
6592

66-
function check_co_all_with_all_true() result(result_)
67-
type(Result_t) :: result_
68-
logical all_true
69-
70-
all_true=.true.
71-
72-
call co_all(all_true)
73-
result_ = assert_that(all_true, "co_all argument remains .true. after call with all arguments true")
74-
end function
75-
76-
function check_co_all_with_one_false() result(result_)
77-
type(Result_t) :: result_
78-
logical all_true
79-
80-
all_true = merge(.false., .true., this_image()==1)
81-
call co_all(all_true)
82-
result_ = assert_not(all_true, "co_all argument is .false. after call with one argument false")
83-
end function
84-
8593
end module

tests/single_image_intrinsics_test.f90 renamed to tests/single_image_intrinsics_test.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
!
77
module single_image_intrinsics_test
88
use Vegetables, only: Result_t, Test_Item_t, describe, it, assert_equals
9+
#ifdef COMPILER_LACKS_FINDLOC
910
use emulated_intrinsics_interface, only : findloc
11+
#endif
1012

1113
implicit none
1214
private
@@ -93,4 +95,3 @@ function check_nonexistent_character_value() result(result_)
9395
end function
9496

9597
end module
96-

0 commit comments

Comments
 (0)