11module object_m_test
2- ! ! author: Damian Rouson
3- ! !
4- ! ! summary: verify object pattern asbtract parent
5- use vegetables, only: &
6- result_t, input_t, integer_input_t, test_item_t, & ! types
7- describe, it, assert_equals, assert_that, assert_not ! functions
8- use object_m, only : object_t
9- implicit none
2+ ! ! Verify object pattern asbtract parent
3+ use test_m, only : test_t, test_result_t
4+ use object_m, only : object_t
5+ implicit none
106
11- private
12- public :: test_object
7+ private
8+ public :: object_test_t
139
14- type, extends(object_t) :: subject
15- contains
16- procedure write_formatted
17- end type
10+ type, extends(test_t) :: object_test_t
11+ contains
12+ procedure , nopass :: subject
13+ procedure , nopass :: results
14+ end type
15+
16+ type, extends(object_t) :: subject_t
17+ contains
18+ procedure write_formatted
19+ end type
1820
1921contains
2022
21- function test_object () result(tests)
22- type (test_item_t) tests
23+ pure function subject () result(specimen)
24+ character (len= :), allocatable :: specimen
25+ specimen = " The object_m type"
26+ end function
27+
28+ pure function results () result(test_results)
29+ type (test_result_t), allocatable :: test_results(:)
2330
24- tests = describe( &
25- " object class" , &
26- [it( &
27- " .not. user_defined() if only default-initialized" , &
28- check_default_initialization), &
29- it( &
30- " user_defined() after call mark_as_defined" , &
31- check_mark_as_defined)])
31+ test_results = [ &
32+ test_result_t(" .not. user_defined() if only default-initialized" , check_default_initialization()), &
33+ test_result_t(" user_defined() after call mark_as_defined" , check_mark_as_defined()) &
34+ ]
3235 end function
3336
34- function check_default_initialization () result(result_ )
37+ pure function check_default_initialization () result(passed )
3538 ! ! Verify that user_defined() is .false. for a default-initialied object
36- class(object_t), allocatable :: object
37- type (result_t) result_
38-
39- allocate (subject :: object)
39+ class(object_t), allocatable :: object
40+ logical passed
4041
41- result_ = assert_not(object% user_defined())
42+ allocate (subject_t :: object)
43+ passed = .not. object% user_defined()
4244 end function
4345
44- function check_mark_as_defined () result(result_ )
46+ pure function check_mark_as_defined () result(passed )
4547 ! ! Verify that mark_as_defined results in user_defined() being .true.
4648 class(object_t), allocatable :: object
47- type (result_t) result_
48-
49- allocate (subject :: object)
49+ logical passed
5050
51+ allocate (subject_t :: object)
5152 call object% mark_as_defined
52- result_ = assert_that( object% user_defined() )
53+ passed = object% user_defined()
5354 end function
5455
5556 subroutine write_formatted (self , unit , iotype , v_list , iostat , iomsg )
56- class(subject ), intent (in ) :: self
57+ class(subject_t ), intent (in ) :: self
5758 integer , intent (in ) :: unit
5859 character (* ), intent (in ) :: iotype
5960 integer , intent (in ) :: v_list(:)
@@ -67,7 +68,7 @@ subroutine write_formatted(self, unit, iotype, v_list, iostat, iomsg)
6768 iomsg = " "
6869 case default
6970 iostat = - 1
70- iomsg = " object_m_test: subject %write_formatted iotype received unsupported iotype " // iotype
71+ iomsg = " object_m_test: subject_t %write_formatted iotype received unsupported iotype " // iotype
7172 end select
7273
7374 associate( unused = > v_list)
0 commit comments