Skip to content

Commit

Permalink
refac(co_{min,max}_test): document, rename vars
Browse files Browse the repository at this point in the history
This commit adds comments and renames variables to make the logic
of the caf_co_min and caf_co_max tests more transparent.
  • Loading branch information
rouson committed Dec 28, 2024
1 parent 8894464 commit 3746956
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
23 changes: 13 additions & 10 deletions test/caf_co_max_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,24 @@ function max_double_precision_2D_array() result(result_)
function max_elements_in_2D_string_arrays() result(result_)
type(result_t) result_
character(len=*), parameter :: script(*,*,*) = reshape( &
[ "To be ","or not " &
, "to ","be. " &

, "that ","is " &
, "the ","question"], &
[ "To be ","or not " & ! images with odd image
, "to ","be. " & ! numbers get this slice
! ----------------------
, "that ","is " & ! images with even image
, "the ","question"], & ! numbers get this slice
[2,2,2])
character(len=len(script)), dimension(size(script,1),size(script,2)) :: scramlet, expected
character(len=len(script)), dimension(size(script,1),size(script,2)) :: slice
integer me, ni

call prif_this_image_no_coarray(this_image=me)
call prif_num_images(ni)
scramlet = script(:,:,mod(me-1,size(script,3))+1)
call prif_co_max(scramlet)
expected = maxval(script(:,:,1:min(ni,size(script,3))), dim=3)
result_ = assert_that(all(expected == scramlet),"all(expected == scramlet)")
associate(slice_number => mod(me-1,size(script,3)) + 1)
slice = script(:,:,slice_number)
end associate
call prif_co_max(slice)
associate(expected => maxval(script(:,:,1:min(ni,size(script,3))), dim=3))
result_ = assert_that(all(expected == slice),"all(expected == scramlet)")
end associate
end function

function reverse_alphabetize_default_character_scalars() result(result_)
Expand Down
23 changes: 13 additions & 10 deletions test/caf_co_min_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,24 @@ function min_double_precision_2D_array() result(result_)
function min_elements_in_2D_string_arrays() result(result_)
type(result_t) result_
character(len=*), parameter :: script(*,*,*) = reshape( &
[ "To be ","or not " &
, "to ","be. " &

, "that ","is " &
, "the ","question"], &
[ "To be ","or not " & ! images with odd image
, "to ","be. " & ! numbers get this slice
! ----------------------
, "that ","is " & ! images with even image
, "the ","question"], & ! numbers get this slice
[2,2,2])
character(len=len(script)), dimension(size(script,1),size(script,2)) :: scramlet, expected
character(len=len(script)), dimension(size(script,1),size(script,2)) :: slice
integer me, ni

call prif_this_image_no_coarray(this_image=me)
call prif_num_images(ni)
scramlet = script(:,:,mod(me-1,size(script,3))+1)
call prif_co_min(scramlet)
expected = minval(script(:,:,1:min(ni,size(script,3))), dim=3)
result_ = assert_that(all(expected == scramlet),"all(expected == scramlet)")
associate(slice_number => mod(me-1,size(script,3)) + 1)
slice = script(:,:,slice_number)
end associate
call prif_co_min(slice)
associate(expected => minval(script(:,:,1:min(ni,size(script,3))), dim=3))
result_ = assert_that(all(expected == slice),"all(expected == scramlet)")
end associate
end function

function alphabetically_1st_scalar_string() result(result_)
Expand Down

0 comments on commit 3746956

Please sign in to comment.