Skip to content

Commit 15b6009

Browse files
committed
refac(formats_test): enable selective testing
1 parent 5999f56 commit 15b6009

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

src/sourcery_m.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module sourcery_m
77
use sourcery_file_m, only : file_t
88
use sourcery_string_m, only : string_t, operator(.cat.)
99
use sourcery_test_m, only : test_t, test_description_substring
10-
use sourcery_test_description_m, only : test_description_t
10+
use sourcery_test_description_m, only : test_description_t, test_function_i
1111
use sourcery_test_result_m, only : test_result_t
1212
use sourcery_user_defined_collectives_m, only : co_all
1313

test/formats_test.f90 renamed to test/formats_test.F90

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module formats_test_m
22
!! Verify that format strings provide the desired formatting
3-
use sourcery_m, only : separated_values, test_t, test_result_t
3+
use sourcery_m, only : &
4+
separated_values, test_t, test_result_t, test_description_t, test_function_i, test_description_substring, string_t
45
implicit none
56

67
private
@@ -21,13 +22,32 @@ pure function subject() result(specimen)
2122

2223
function results() result(test_results)
2324
type(test_result_t), allocatable :: test_results(:)
25+
type(test_description_t), allocatable :: test_descriptions(:)
26+
27+
#ifndef __GFORTRAN__
28+
test_descriptions = [ &
29+
test_description_t("yielding a comma-separated list of real numbers", check_csv_reals), &
30+
test_description_t("yielding a space-separated list of complex numbers", check_space_separated_complex), &
31+
test_description_t("yielding a comma- and space-separated list of character values", check_csv_character), &
32+
test_description_t("yielding a new-line-separated list of integer numbers", check_new_line_separated_integers) &
33+
]
34+
#else
35+
! Work around missing Fortran 2008 feature: associating a procedure actual argument with a procedure pointer dummy argument:
36+
procedure(test_function_i), pointer :: check_csv_reals_ptr, check_space_ptr, check_csv_char_ptr, check_new_line_ptr
37+
check_csv_reals_ptr => check_csv_reals
38+
check_space_ptr => check_space_separated_complex
39+
check_csv_char_ptr => check_csv_character
40+
check_new_line_ptr => check_new_line_separated_integers
41+
test_descriptions = [ &
42+
test_description_t(string_t("yielding a comma-separated list of real numbers"), check_csv_reals_ptr), &
43+
test_description_t(string_t("yielding a space-separated list of complex numbers"), check_space_ptr), &
44+
test_description_t(string_t("yielding a comma- and space-separated list of character values"), check_csv_char_ptr), &
45+
test_description_t(string_t("yielding a new-line-separated list of integer numbers"), check_new_line_ptr) &
46+
]
47+
#endif
48+
test_descriptions = pack(test_descriptions, test_descriptions%contains_text(string_t(test_description_substring)))
49+
test_results = test_descriptions%run()
2450

25-
test_results = [ &
26-
test_result_t("yielding a comma-separated list of real numbers", check_csv_reals()), &
27-
test_result_t("yielding a space-separated list of complex numbers", check_space_separated_complex()), &
28-
test_result_t("yielding a comma- and space-separated list of character values", check_csv_character()), &
29-
test_result_t("yielding a new-line-separated list of integer numbers", check_new_line_separated_integers()) &
30-
]
3151
end function
3252

3353
function check_csv_reals() result(test_passes)

test/test_result_test.F90

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
module test_result_test_m
22
!! Verify test_result_t object behavior
3-
use sourcery_string_m, only : string_t
4-
use sourcery_test_result_m, only : test_result_t
5-
use sourcery_test_description_m, only : test_description_t
6-
use sourcery_test_m, only : test_t, test_description_substring
3+
use sourcery_m, only : string_t, test_result_t, test_description_t, test_t, test_description_substring
74
#ifdef __GFORTRAN__
85
use sourcery_test_description_m, only : test_function_i
96
#endif

0 commit comments

Comments
 (0)