Skip to content

Commit 91ff45f

Browse files
author
Damian Rouson
authored
Merge pull request #3 from sourceryinstitute/add-tests
Add test suite with one trivially passing test
2 parents a51a5a2 + 2cc4c99 commit 91ff45f

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

fpm.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ copyright = "2020 Sourcery Institute"
88
[dev-dependencies]
99
vegetables = {git = "https://gitlab.com/everythingfunctional/vegetables", tag = "v5.1.1"}
1010

11-
#[[test]]
12-
#name="inputOutput"
13-
#source-dir="tests/unit/input-output"
14-
#main="main.f90"
11+
[[test]]
12+
name="unit"
13+
source-dir="tests"
14+
main="main.f90"

src/array_functions_interface.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ module array_functions_interface
3333

3434
interface
3535

36-
pure module function column_vectors(vector_field) RESULT(array_of_3D_column_vectors)
36+
pure module function column_vectors(vector_field) result(array_of_3D_column_vectors)
3737
!! Result is array of 3D column vectors of dimension (space_dim,nx*ny*nz) reshaped from vector-field argument
3838
!! of dimension (nx,ny,nz,space_dim)
3939
implicit none
4040
real, dimension(:,:,:,:), intent(in) :: vector_field
4141
real, dimension(:,:), allocatable :: array_of_3D_column_vectors
4242
end function
4343

44-
pure module function concatenate_columns(a, b) RESULT(concatenated)
44+
pure module function concatenate_columns(a, b) result(concatenated)
4545
!! Result contains the concatenation of the columns of argument a with the columns of argument b
4646
implicit none
4747
real, dimension(:,:), intent(in) :: a, b
4848
real, dimension(:,:), allocatable :: concatenated
4949
end function
5050

51-
pure module function concatenate_rows(a, b) RESULT(concatenated)
51+
pure module function concatenate_rows(a, b) result(concatenated)
5252
!! Result contains the concatenation of the rows of argument a with the rows of argument b
5353
implicit none
5454
real, dimension(:,:), intent(in) :: a, b

tests/example_test.f90

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module example_test
2+
use Vegetables_m, only: Result_t, TestItem_t, describe, it, succeed
3+
4+
implicit none
5+
private
6+
7+
public :: test_example
8+
contains
9+
function test_example() result(tests)
10+
type(TestItem_t) :: tests
11+
12+
tests = describe(&
13+
"something", &
14+
[it( &
15+
"does a thing", &
16+
check_example)])
17+
end function
18+
19+
function check_example() result(result_)
20+
type(Result_t) :: result_
21+
22+
result_ = succeed("For now")
23+
end function
24+
end module

tests/main.f90

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
program main
2+
use example_test, only : test_example
3+
use Vegetables_m, only: TestItem_t, testThat, runTests
4+
5+
implicit none
6+
7+
call run()
8+
contains
9+
subroutine run()
10+
type(TestItem_t) :: tests
11+
type(TestItem_t) :: individual_tests(1)
12+
13+
individual_tests(1) = test_example()
14+
tests = testThat(individual_tests)
15+
16+
call runTests(tests)
17+
end subroutine run
18+
end program

0 commit comments

Comments
 (0)