1+ module sourcery_test_description_m
2+ ! ! Define an abstraction for describing test intentions and test functions
3+ use sourcery_string_m, only : string_t
4+ use sourcery_test_result_m, only : test_result_t
5+ implicit none
6+
7+ private
8+ public :: test_description_t
9+ #ifdef __GFORTRAN__
10+ public :: test_function_i
11+ #endif
12+
13+ abstract interface
14+ function test_function_i () result(passes)
15+ implicit none
16+ logical passes
17+ end function
18+ end interface
19+
20+ type test_description_t
21+ ! ! Encapsulate test descriptions and test-functions
22+ private
23+ type (string_t) description_
24+ procedure (test_function_i), pointer , nopass :: test_function_ = > null ()
25+ contains
26+ procedure run
27+ procedure contains_text
28+ end type
29+
30+ interface test_description_t
31+
32+ module function construct (description , test_function ) result(test_description)
33+ ! ! The result is a test_description_t object with the components defined by the dummy arguments
34+ implicit none
35+ type (string_t), intent (in ) :: description
36+ procedure (test_function_i), intent (in ), pointer :: test_function
37+ type (test_description_t) test_description
38+ end function
39+
40+ end interface
41+
42+ interface
43+
44+ impure elemental module function run(self) result(test_result)
45+ ! ! The result encapsulates the test description and test outcome
46+ implicit none
47+ class(test_description_t), intent (in ) :: self
48+ type (test_result_t) test_result
49+ end function
50+
51+ impure elemental module function contains_text(self, substring) result(match)
52+ ! ! The result is .true. if the test description includes the value of substring
53+ implicit none
54+ class(test_description_t), intent (in ) :: self
55+ type (string_t), intent (in ) :: substring
56+ logical match
57+ end function
58+
59+ end interface
60+
61+ end module sourcery_test_description_m
0 commit comments