Skip to content

Commit f5dc594

Browse files
authored
Merge pull request #31 from sourceryinstitute/replace-vegetables
Replace vegetables
2 parents 5b6d987 + 7856def commit f5dc594

16 files changed

+407
-332
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: Build and Deploy Documentation
22

33
on: [push, pull_request]
44

5+
56
jobs:
67
Build:
7-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-22.04
89

910
steps:
1011
- name: Checkout code
@@ -13,13 +14,13 @@ jobs:
1314
- name: Install Dependencies Ubuntu
1415
run: |
1516
sudo apt-get update
16-
sudo apt install -y python-dev python build-essential graphviz
17-
sudo pip install ford
17+
sudo apt install -y python3-dev python3 build-essential graphviz
18+
sudo pip install ford markdown==3.3.4
1819
1920
- name: Build Developer Documenation
2021
run: |
2122
cd doc
22-
ford ford-documentation.md
23+
ford ford.md
2324
2425
- name: Upload Documentation
2526
uses: actions/upload-artifact@v2
File renamed without changes.

fpm.toml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
name = "sourcery"
2-
version = "1.0.0"
2+
version = "3.1.0"
33
license = "BSD"
44
author = ["Damian Rouson"]
5-
maintainer = "damian@sourceryinstitute.org"
6-
copyright = "2020 Sourcery Institute"
5+
maintainer = "damian@archaeologic.codes"
6+
copyright = "2020-2022 Sourcery Institute"
77

88
[dependencies]
9-
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.0.0"}
10-
11-
[dev-dependencies]
12-
vegetables = {git = "https://gitlab.com/everythingfunctional/vegetables", tag = "v7.2.0"}
13-
14-
[[test]]
15-
name="unit"
16-
source-dir="tests"
17-
main="main.f90"
9+
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.4.0"}

src/test_m.F90

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module test_m
2+
!! Define an abstract test_t type with deferred bindings ("subject" and "results")
3+
!! used by a type-bound procedure ("report") for reporting test results. The "report"
4+
!! procedure thus represents an implementation of the Template Method pattern.
5+
use test_result_m, only : test_result_t
6+
implicit none
7+
8+
private
9+
public :: test_t, test_result_t
10+
11+
type, abstract :: test_t
12+
!! Facilitate testing and test reporting
13+
contains
14+
procedure(subject_interface), nopass, deferred :: subject
15+
procedure(results_interface), nopass, deferred :: results
16+
procedure :: report
17+
end type
18+
19+
abstract interface
20+
21+
pure function subject_interface() result(specimen)
22+
!! The result is the name of the test specimen (the subject of testing)
23+
character(len=:), allocatable :: specimen
24+
end function
25+
26+
function results_interface() result(test_results)
27+
!! The result is an array of test results for subsequent reporting in the "report" type-bound procedure
28+
import test_result_t
29+
type(test_result_t), allocatable :: test_results(:)
30+
end function
31+
32+
end interface
33+
34+
interface
35+
36+
module subroutine report(test)
37+
!! Report test results
38+
implicit none
39+
class(test_t), intent(in) :: test
40+
end subroutine
41+
42+
end interface
43+
44+
end module test_m

src/test_result_m.f90

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module test_result_m
2+
!! Define an abstraction for describing test intentions and results
3+
implicit none
4+
5+
private
6+
public :: test_result_t
7+
8+
type test_result_t
9+
!! Encapsulate test descriptions and outcomes and reporting
10+
private
11+
character(len=:), allocatable :: description_
12+
logical passed_
13+
contains
14+
procedure :: characterize
15+
end type
16+
17+
interface test_result_t
18+
19+
pure module function construct(description, passed) result(test_result)
20+
!! The result is a test_result_t object with the components defined by the dummy arguments
21+
implicit none
22+
character(len=*), intent(in) :: description
23+
logical, intent(in) :: passed
24+
type(test_result_t) test_result
25+
end function
26+
27+
end interface
28+
29+
interface
30+
31+
pure module function characterize(self) result(characterization)
32+
!! The result is a character description of the test and its outcome
33+
implicit none
34+
class(test_result_t), intent(in) :: self
35+
character(len=:), allocatable :: characterization
36+
end function
37+
38+
end interface
39+
40+
end module test_result_m

src/test_result_s.f90

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
submodule(test_result_m) test_result_s
2+
implicit none
3+
4+
contains
5+
6+
module procedure construct
7+
test_result%description_ = description
8+
test_result%passed_ = passed
9+
end procedure
10+
11+
module procedure characterize
12+
characterization = merge("passes on ", "FAILS on ", self%passed_) // self%description_ // "."
13+
end procedure
14+
15+
end submodule test_result_s

src/test_s.F90

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
submodule(test_m) test_s
2+
#ifdef XLF
3+
use test_result_m, only : test_result_t
4+
#endif
5+
implicit none
6+
7+
contains
8+
9+
module procedure report
10+
integer i
11+
#ifdef XLF
12+
type(test_result_t), allocatable :: test_results(:)
13+
test_results = test%results()
14+
#else
15+
associate(test_results => test%results())
16+
#endif
17+
18+
print *
19+
print *, test%subject()
20+
21+
do i=1,size(test_results)
22+
print *," ",test_results(i)%characterize()
23+
end do
24+
#ifndef XLF
25+
end associate
26+
#endif
27+
end procedure
28+
29+
end submodule test_s

0 commit comments

Comments
 (0)