Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Update pFUnit to use v2 template interfaces #464

Closed
Closed
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
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Updated pFUnit to use v2 template interfaces
- Added `-quiet` flag for NAG Fortran
- Remove `macos-11` from GitHub Actions, add `macos-12` and `gfortran-14` to Ubuntu 24.04

Expand Down
2 changes: 1 addition & 1 deletion extern/fArgParse
6 changes: 3 additions & 3 deletions src/funit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ function(funit_target_link_pfunit funit_target)
target_link_libraries (${funit_target} PUBLIC OpenMP::OpenMP_Fortran)
endif ()

if (NOT TARGET GFTL::gftl)
if (NOT TARGET GFTL::gftl-v2)
message(FATAL_ERROR "Could not find gFTL. This should not happen.")
endif ()

if (NOT TARGET GFTL_SHARED::gftl-shared)
if (NOT TARGET GFTL_SHARED::gftl-shared-v2)
message(FATAL_ERROR "Could not find gFTL-shared. This should not happen.")
endif ()

target_link_libraries (${funit_target} PUBLIC GFTL::gftl GFTL_SHARED::gftl-shared FARGPARSE::fargparse)
target_link_libraries (${funit_target} PUBLIC GFTL::gftl-v2 GFTL_SHARED::gftl-shared-v2 GFTL_SHARED::gftl-shared-v2-as-default FARGPARSE::fargparse)
target_include_directories(${funit_target} PUBLIC
$<BUILD_INTERFACE:${PFUNIT_SOURCE_DIR}/include>
)
Expand Down
10 changes: 5 additions & 5 deletions src/funit/core/AbstractPattern.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ end module PF_AbstractPattern

module PF_AbstractPatternVector
use PF_AbstractPattern
#define _type class (AbstractPattern)
#define _allocatable
#define _vector AbstractPatternVector
#define _iterator AbstractPatternVectorIterator
#define T AbstractPattern
#define T_polymorphic
#define Vector AbstractPatternVector
#define VectorIterator AbstractPatternVectorIterator

#include "templates/vector.inc"
#include "vector/template.inc"

end module PF_AbstractPatternVector
7 changes: 4 additions & 3 deletions src/funit/core/ExceptionList.F90
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ logical function catch_message(this, message, preserve) result(found)

iter = this%begin()
do while (iter /= this%end())
e => iter%get()
e => iter%of()
if (e%getMessage() == message) then
found = .true.
if (.not. preserveMessage(preserve)) call this%erase(iter)
if (.not. preserveMessage(preserve)) iter = this%erase(iter)
return
end if
call iter%next()
Expand All @@ -119,6 +119,7 @@ function catch_next(this, preserve) result(anException)
class (ExceptionList), intent(inOut) :: this
logical, optional, intent(in) :: preserve
type (Exception) :: anException
type (ExceptionVectorIterator) :: iter


if (.not. this%empty()) then
Expand All @@ -134,7 +135,7 @@ function catch_next(this, preserve) result(anException)
#endif
if (preserveMessage(preserve)) return

call this%erase(this%begin())
iter = this%erase(this%begin())
end if

end function catch_next
Expand Down
10 changes: 5 additions & 5 deletions src/funit/core/ExceptionVector.F90
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module PF_ExceptionVector
use PF_Exception

#define _type class(Exception)
#define _allocatable
#define _vector ExceptionVector
#define _iterator ExceptionVectorIterator
#include "templates/vector.inc"
#define T Exception
#define T_polymorphic
#define Vector ExceptionVector
#define VectorIterator ExceptionVectorIterator
#include "vector/template.inc"

end module PF_ExceptionVector
15 changes: 7 additions & 8 deletions src/funit/core/TestAnnotation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ end module pf_TestAnnotation
module pf_StringTestAnnotationMap
use pf_TestAnnotation

#define _map StringTestAnnotationMap
#define _iterator StringTestAnnotationMapIterator
#define _pair StringTestAnnotationPair
#include "types/key_deferredLengthString.inc"
#define _value_allocatable
#define _value class(TestAnnotation)
#define _alt
#include "templates/map.inc"
#define Map StringTestAnnotationMap
#define MapIterator StringTestAnnotationMapIterator
#define Pair StringTestAnnotationPair
#define Key __CHARACTER_DEFERRED
#define T TestAnnotation
#define T_polymorphic
#include "map/template.inc"

end module pf_StringTestAnnotationMap
13 changes: 9 additions & 4 deletions src/funit/core/TestFailureVector.F90
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
module PF_TestFailureVector
use PF_TestFailure
#define _type type (TestFailure)
#define _vector TestFailureVector
#define _iterator TestFailureVectorIterator
#include "templates/vector.inc"
!#define _type type (TestFailure)
!#define _vector TestFailureVector
!#define _iterator TestFailureVectorIterator
!#include "templates/vector.inc"

#define T TestFailure
#define Vector TestFailureVector
#define VectorIterator TestFailureVectorIterator
#include "vector/template.inc"

end module PF_TestFailureVector
10 changes: 5 additions & 5 deletions src/funit/core/TestListenerVector.F90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module PF_TestListenerVector
use PF_TestListener
#define _type class (TestListener)
#define _allocatable
#define _vector TestListenerVector
#define _iterator TestListenerVectorIterator
#include "templates/vector.inc"
#define T TestListener
#define T_polymorphic
#define Vector TestListenerVector
#define VectorIterator TestListenerVectorIterator
#include "vector/template.inc"

end module PF_TestListenerVector
2 changes: 1 addition & 1 deletion src/funit/core/TestSuite.F90
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ recursive function filter(this, a_filter) result(new_suite)

iter = this%tests%begin()
do while (iter /= this%tests%end())
t => iter%get()
t => iter%of()

select type (t)
class is (TestSuite)
Expand Down
10 changes: 5 additions & 5 deletions src/funit/core/TestVector.F90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module PF_TestVector
use PF_Test
#define _type class (Test)
#define _allocatable
#define _vector TestVector
#define _iterator TestVectorIterator
#include "templates/vector.inc"
#define T Test
#define T_polymorphic
#define Vector TestVector
#define VectorIterator TestVectorIterator
#include "vector/template.inc"

end module PF_TestVector
4 changes: 2 additions & 2 deletions src/funit/fhamcrest/AllOf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ logical function matches(this, actual_value)

iter = this%matchers%begin()
do while (iter /= this%matchers%end())
matcher => iter%get()
matcher => iter%of()
if (.not. matcher%matches(actual_value)) then
matches = .false.
return
Expand Down Expand Up @@ -120,7 +120,7 @@ subroutine describe_to_op(this, description, operator)
allocate(matchers_as_SelfDescribing) ! ensure empty at each iteration
iter = this%matchers%begin()
do while (iter /= this%matchers%end())
call matchers_as_SelfDescribing%push_back(iter%get())
call matchers_as_SelfDescribing%push_back(iter%of())
call iter%next()
end do

Expand Down
4 changes: 2 additions & 2 deletions src/funit/fhamcrest/AnyOf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ logical function matches(this, actual_value)

iter = this%matchers%begin()
do while (iter /= this%matchers%end())
matcher => iter%get()
matcher => iter%of()
if (matcher%matches(actual_value)) then
matches = .true.
return
Expand Down Expand Up @@ -125,7 +125,7 @@ subroutine describe_to_op(this, description, operator)
allocate(matchers_as_SelfDescribing) ! ensure empty at each iteration
iter = this%matchers%begin()
do while (iter /= this%matchers%end())
call matchers_as_SelfDescribing%push_back(iter%get())
call matchers_as_SelfDescribing%push_back(iter%of())
call iter%next()
end do

Expand Down
2 changes: 1 addition & 1 deletion src/funit/fhamcrest/BaseDescription.F90
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ subroutine append_list_vector(this, start, separator, end, values)
iter = values%begin()
do while (iter /= values%end())
if (separate) call this%append(separator)
call this%append_description_of(iter%get())
call this%append_description_of(iter%of())
separate = .true.
call iter%next()
end do
Expand Down
21 changes: 11 additions & 10 deletions src/funit/fhamcrest/MatcherVector.F90
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
module pf_MatcherVector
use pf_AbstractMatcher

#define _type class(AbstractMatcher)
#define _vector MatcherVector
#define _vectorIterator MatcherVectorIterator
#define _allocatable
#define T AbstractMatcher
#define T_polymorphic
#define Vector MatcherVector
#define VectorIterator MatcherVectorIterator

#include "vector/template.inc"

#undef VectorIterator
#undef Vector
#undef T_polymorphic
#undef T

#include "templates/vector.inc"

#undef _allocatable
#undef _vectorIterator
#undef _vector
#undef _type

end module pf_MatcherVector
20 changes: 10 additions & 10 deletions src/funit/fhamcrest/SelfDescribingVector.F90
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module pf_SelfDescribingVector
use pf_SelfDescribing

#define _type class(SelfDescribing)
#define _vector SelfDescribingVector
#define _vectorIterator SelfDescribingVectorIterator
#define _allocatable
#define T SelfDescribing
#define T_polymorphic
#define Vector SelfDescribingVector
#define VectorIterator SelfDescribingVectorIterator

#include "templates/vector.inc"
#include "vector/template.inc"

#undef VectorIterator
#undef Vector
#undef T_polymorphic
#undef T

#undef _allocatable
#undef _vectorIterator
#undef _vector
#undef _type

end module pf_SelfDescribingVector
Loading