Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: Build and Deploy Documentation

on: [push, pull_request]


jobs:
Build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout code
Expand All @@ -13,13 +14,13 @@ jobs:
- name: Install Dependencies Ubuntu
run: |
sudo apt-get update
sudo apt install -y python-dev python build-essential graphviz
sudo pip install ford
sudo apt install -y python3-dev python3 build-essential graphviz
sudo pip install ford markdown==3.3.4

- name: Build Developer Documenation
run: |
cd doc
ford ford-documentation.md
ford ford.md

- name: Upload Documentation
uses: actions/upload-artifact@v2
Expand Down
File renamed without changes.
16 changes: 4 additions & 12 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
name = "sourcery"
version = "1.0.0"
version = "3.1.0"
license = "BSD"
author = ["Damian Rouson"]
maintainer = "damian@sourceryinstitute.org"
copyright = "2020 Sourcery Institute"
maintainer = "damian@archaeologic.codes"
copyright = "2020-2022 Sourcery Institute"

[dependencies]
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.0.0"}

[dev-dependencies]
vegetables = {git = "https://gitlab.com/everythingfunctional/vegetables", tag = "v7.2.0"}

[[test]]
name="unit"
source-dir="tests"
main="main.f90"
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.4.0"}
44 changes: 44 additions & 0 deletions src/test_m.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module test_m
!! Define an abstract test_t type with deferred bindings ("subject" and "results")
!! used by a type-bound procedure ("report") for reporting test results. The "report"
!! procedure thus represents an implementation of the Template Method pattern.
use test_result_m, only : test_result_t
implicit none

private
public :: test_t, test_result_t

type, abstract :: test_t
!! Facilitate testing and test reporting
contains
procedure(subject_interface), nopass, deferred :: subject
procedure(results_interface), nopass, deferred :: results
procedure :: report
end type

abstract interface

pure function subject_interface() result(specimen)
!! The result is the name of the test specimen (the subject of testing)
character(len=:), allocatable :: specimen
end function

function results_interface() result(test_results)
!! The result is an array of test results for subsequent reporting in the "report" type-bound procedure
import test_result_t
type(test_result_t), allocatable :: test_results(:)
end function

end interface

interface

module subroutine report(test)
!! Report test results
implicit none
class(test_t), intent(in) :: test
end subroutine

end interface

end module test_m
40 changes: 40 additions & 0 deletions src/test_result_m.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module test_result_m
!! Define an abstraction for describing test intentions and results
implicit none

private
public :: test_result_t

type test_result_t
!! Encapsulate test descriptions and outcomes and reporting
private
character(len=:), allocatable :: description_
logical passed_
contains
procedure :: characterize
end type

interface test_result_t

pure module function construct(description, passed) result(test_result)
!! The result is a test_result_t object with the components defined by the dummy arguments
implicit none
character(len=*), intent(in) :: description
logical, intent(in) :: passed
type(test_result_t) test_result
end function

end interface

interface

pure module function characterize(self) result(characterization)
!! The result is a character description of the test and its outcome
implicit none
class(test_result_t), intent(in) :: self
character(len=:), allocatable :: characterization
end function

end interface

end module test_result_m
15 changes: 15 additions & 0 deletions src/test_result_s.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
submodule(test_result_m) test_result_s
implicit none

contains

module procedure construct
test_result%description_ = description
test_result%passed_ = passed
end procedure

module procedure characterize
characterization = merge("passes on ", "FAILS on ", self%passed_) // self%description_ // "."
end procedure

end submodule test_result_s
29 changes: 29 additions & 0 deletions src/test_s.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
submodule(test_m) test_s
#ifdef XLF
use test_result_m, only : test_result_t
#endif
implicit none

contains

module procedure report
integer i
#ifdef XLF
type(test_result_t), allocatable :: test_results(:)
test_results = test%results()
#else
associate(test_results => test%results())
#endif

print *
print *, test%subject()

do i=1,size(test_results)
print *," ",test_results(i)%characterize()
end do
#ifndef XLF
end associate
#endif
end procedure

end submodule test_s
Loading