11module 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)
0 commit comments