3 ! Test the fix for PR87151 by exercising deferred length character
6 ! Based on the contribution by Valery Weber <valeryweber@hotmail.com>
11 character(:), dimension(:), allocatable
:: vc
13 PROCEDURE
, PASS
:: create
14 PROCEDURE
, PASS
:: test_bvec
15 PROCEDURE
, PASS
:: delete
18 subroutine create (this
, switch
)
19 class(bvec_t
), intent(inout
) :: this
22 allocate (character(2)::this
%vc(3))
23 if (len (this
%vc
) .ne
. 2) stop 1 ! The orignal problem. Gave 0.
25 ! Check that reallocation on assign does what it should do as required by
26 ! F2003 7.4.1.3. ie. reallocation occurs because LEN has changed.
27 this
%vc
= ['abcd','efgh','ijkl']
29 allocate (this
%vc
, source
= ['abcd','efgh','ijkl'])
33 subroutine test_bvec (this
)
34 class(bvec_t
), intent(inout
) :: this
35 character(20) :: buffer
36 if (allocated (this
%vc
)) then
37 if (len (this
%vc
) .ne
. 4) stop 2
38 if (size (this
%vc
) .ne
. 3) stop 3
39 ! Check array referencing and scalarized array referencing
40 if (this
%vc(2) .ne
. 'efgh') stop 4
41 if (any (this
%vc
.ne
. ['abcd','efgh','ijkl'])) stop 5
43 write (buffer
, *) this
%vc
44 if (trim (buffer(2:)) .ne
. 'abcdefghijkl') stop 6
45 ! Make sure that substrings work correctly
46 write (buffer
, *) this
%vc(:)(2:3)
47 if (trim (buffer(2:)) .ne
. 'bcfgjk') stop 7
48 write (buffer
, *) this
%vc(2:)(2:3)
49 if (trim (buffer(2:)) .ne
. 'fgjk') stop 8
51 end subroutine test_bvec
53 subroutine delete (this
)
54 class(bvec_t
), intent(inout
) :: this
55 if (allocated (this
%vc
)) then
64 call a
%create (.false
.)
68 call a
%create (.true
.)