forked from sourceryinstitute/julienne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(diagnosis_t): assert diagnostics allocated
- Loading branch information
Showing
7 changed files
with
159 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute | ||
! Terms of use are as specified in LICENSE.txt | ||
module julienne_diagnosis_m | ||
!! Define an abstraction for describing test outcomes and diagnostic information | ||
use julienne_string_m, only : string_t | ||
implicit none | ||
|
||
private | ||
public :: diagnosis_t | ||
|
||
type diagnosis_t | ||
!! Encapsulate test outcome and diagnostic information | ||
private | ||
logical passed_ | ||
character(len=:), allocatable :: diagnostics_ | ||
contains | ||
procedure passed | ||
procedure diagnostics | ||
end type | ||
|
||
interface diagnosis_t | ||
|
||
elemental module function construct_from_string_t(passed, diagnostics) result(diagnosis) | ||
!! The result is a diagnosis_t object with the components defined by the dummy arguments | ||
implicit none | ||
logical, intent(in) :: passed | ||
type(string_t), intent(in) :: diagnostics | ||
type(diagnosis_t) diagnosis | ||
end function | ||
|
||
elemental module function construct_from_character(passed, diagnostics) result(diagnosis) | ||
!! The result is a diagnosis_t object with the components defined by the dummy arguments | ||
implicit none | ||
logical, intent(in) :: passed | ||
character(len=*), intent(in) :: diagnostics | ||
type(diagnosis_t) diagnosis | ||
end function | ||
|
||
end interface | ||
|
||
interface | ||
|
||
elemental module function passed(self) result(test_passed) | ||
!! The result is .true. if the test passed | ||
implicit none | ||
class(diagnosis_t), intent(in) :: self | ||
logical test_passed | ||
end function | ||
|
||
elemental module function diagnostics(self) result(diagnostics_string) | ||
!! The result is a diagnostic string describing a failed test or a zero-length string if the test passed | ||
implicit none | ||
class(diagnosis_t), intent(in) :: self | ||
type(string_t) diagnostics_string | ||
end function | ||
|
||
end interface | ||
|
||
end module julienne_diagnosis_m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute | ||
! Terms of use are as specified in LICENSE.txt | ||
|
||
#include "assert_macros.h" | ||
|
||
submodule(julienne_diagnosis_m) julienne_diagnosis_s | ||
use assert_m | ||
implicit none | ||
contains | ||
module procedure construct_from_string_t | ||
diagnosis%passed_ = passed | ||
diagnosis%diagnostics_ = diagnostics | ||
end procedure | ||
|
||
module procedure construct_from_character | ||
diagnosis%passed_ = passed | ||
diagnosis%diagnostics_ = diagnostics | ||
end procedure | ||
|
||
module procedure passed | ||
test_passed = self%passed_ | ||
end procedure | ||
|
||
module procedure diagnostics | ||
call_assert(allocated(self%diagnostics_)) | ||
diagnostics_string = string_t(self%diagnostics_) | ||
end procedure | ||
end submodule julienne_diagnosis_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters