Skip to content

Commit 971eb74

Browse files
committed
feat(test_diagnosis): .and. aggregates diagnoses
This commit adds support and a corresponding unit test for constructing a test_diagnosis_t object from a test_diagnosis_t expression of the form (0 .lessThanOrEqualTo. 1) .and. (2 .equalsExpected. 2) where the two .and. operands are test_diagnosis_t objects, which in the above case happen to be the result expression evaluations.
1 parent f545550 commit 971eb74

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

src/julienne/julienne_test_diagnosis_m.F90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module julienne_test_diagnosis_m
1111
private
1212
public :: test_diagnosis_t
1313
public :: operator(.all.)
14+
public :: operator(.and.)
1415
public :: operator(.approximates.)
1516
public :: operator(.within.)
1617
public :: operator(.equalsExpected.)
@@ -56,6 +57,16 @@ pure module function aggregate_diagnosis(diagnoses) result(diagnosis)
5657

5758
end interface
5859

60+
interface operator(.and.)
61+
62+
elemental module function and(lhs, rhs) result(diagnosis)
63+
implicit none
64+
type(test_diagnosis_t), intent(in) :: lhs, rhs
65+
type(test_diagnosis_t) diagnosis
66+
end function
67+
68+
end interface
69+
5970
interface operator(.approximates.)
6071

6172
elemental module function approximates_real(actual, expected) result(operands)

src/julienne/julienne_test_diagnosis_s.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
implicit none
1111
contains
1212

13+
module procedure and
14+
diagnosis = .all. ([lhs,rhs])
15+
end procedure
16+
1317
module procedure aggregate_diagnosis
1418
character(len=*), parameter :: new_line_indent = new_line('') // " "
1519
integer i

src/julienne_m.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module julienne_m
1313
use julienne_test_diagnosis_m, only : &
1414
test_diagnosis_t &
1515
,operator(.all.) &
16+
,operator(.and.) &
1617
,operator(.approximates.) &
1718
,operator(.within.) &
1819
,operator(.equalsExpected.) &

test/test_diagnosis_test_m.F90

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module test_diagnosis_test_m
1717
,diagnosis_function_i &
1818
#endif
1919
,operator(.all.) &
20+
,operator(.and.) &
2021
,operator(.equalsExpected.) &
2122
,operator(.approximates.) &
2223
,operator(.within.) &
@@ -58,6 +59,7 @@ function results() result(test_results)
5859
,test_description_t("contruction from a integer expression of the form 'i .greaterThan. j", check_greater_than_integer) &
5960
,test_description_t("contruction from a integer expression of the form '[i,j] .lessThanOrEqualTo. k", check_less_than_or_equal_to_integer) &
6061
,test_description_t("contruction from a integer expression of the form '[i,j] .greaterThanOrEqualTo. k", check_greater_than_or_equal_to_integer) &
62+
,test_description_t("contruction from a test_diagnostics_t expression of the form 't .and. u'", check_and_operator) &
6163
] )
6264
#else
6365
! Work around missing Fortran 2008 feature: associating a procedure actual argument with a procedure pointer dummy argument:
@@ -68,8 +70,9 @@ function results() result(test_results)
6870
,check_less_than_real_ptr , check_greater_than_real_ptr &
6971
,check_less_than_double_ptr , check_greater_than_double_ptr &
7072
,check_less_than_integer_ptr , check_greater_than_integer_ptr &
71-
,check_less_than_or_equal_to_integer_ptr, check_greater_than_or_equal_to_integer_ptr
72-
73+
,check_less_than_or_equal_to_integer_ptr, check_greater_than_or_equal_to_integer_ptr &
74+
,check_and_operator_ptr
75+
7376
check_approximates_real_ptr => check_approximates_real
7477
check_approximates_double_ptr => check_approximates_double
7578
check_equals_integer_ptr => check_equals_integer
@@ -81,6 +84,7 @@ function results() result(test_results)
8184
check_greater_than_double_ptr => check_greater_than_double
8285
check_greater_than_integer_ptr => check_greater_than_integer
8386
check_greater_than_or_equal_to_integer_ptr => check_greater_than_or_equal_to_integer
87+
check_and_operator_ptr => check_and_operator
8488

8589
descriptions = [ &
8690
test_description_t("contruction from a real expression of the form `x .approximates. y .within. tolerance`" , check_approximates_real_ptr) &
@@ -89,11 +93,12 @@ function results() result(test_results)
8993
,test_description_t("contruction from a real expression of the form 'x .lessThan. y" , check_less_than_real_ptr) &
9094
,test_description_t("contruction from a double precision expression of the form 'x .lessThan. y" , check_less_than_double_ptr) &
9195
,test_description_t("contruction from a integer expression of the form 'i .lessThan. j" , check_less_than_integer_ptr) &
92-
,test_description_t("contruction from a integer expression of the form 'i .lessThanOrEqualTo. j" ) & ! skip check_less_than_or_equal_to_integer_ptr
96+
,test_description_t("contruction from a integer expression of the form 'i .lessThanOrEqualTo. j" ) & ! skip check_less_than_or_equal_to_integer_ptr
9397
,test_description_t("contruction from a real expression of the form 'x .greaterThan. y" , check_greater_than_real_ptr) &
9498
,test_description_t("contruction from a double precision expression of the form 'x .greaterThan. y" , check_greater_than_double_ptr) &
9599
,test_description_t("contruction from a integer expression of the form 'i .greaterThan. j" , check_greater_than_integer_ptr) &
96-
,test_description_t("contruction from a integer expression of the form 'i .greaterThanOrEqualTo. j" ) & ! skip check_greater_than_or_equal_to_integer_ptr
100+
,test_description_t("contruction from a integer expression of the form 'i .greaterThanOrEqualTo. j") & ! skip check_greater_than_or_equal_to_integer_ptr
101+
,test_description_t("contruction from a test_diagnostics_t expression of the form 't .and. u'" ) & ! skip check_and_operator_ptr
97102
]
98103
#endif
99104

@@ -187,4 +192,10 @@ function check_greater_than_or_equal_to_integer() result(test_diagnosis)
187192
test_diagnosis = .all. ([1,2] .greaterThanOrEqualTo. expected_min)
188193
end function
189194

195+
function check_and_operator() result(test_diagnosis)
196+
type(test_diagnosis_t) test_diagnosis
197+
integer, parameter :: expected_min = 1
198+
test_diagnosis = (2 .greaterThanOrEqualTo. expected_min) .and. (1 .equalsExpected. 1)
199+
end function
200+
190201
end module test_diagnosis_test_m

0 commit comments

Comments
 (0)