File: test_strict.f90

package info (click to toggle)
fortran-cli2 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 25,856 kB
  • sloc: f90: 6,172; javascript: 3,423; makefile: 188; sh: 25
file content (57 lines) | stat: -rwxr-xr-x 2,059 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
program test_strict
!> @(#) unnamed to numbers
!! The default for inums, rnums, ... is to convert all unnamed argument values in "unnamed"
use, intrinsic :: iso_fortran_env, only : stderr=>ERROR_UNIT, stdin=>INPUT_UNIT, stdout=>OUTPUT_UNIT
use M_CLI2,  only : set_args, sget, igets, rgets, dgets, lget, set_mode
implicit none
character(len=*),parameter :: it='(1x,*(g0,1x))'
logical,parameter :: T=.true., F=.false.
character(len=:),allocatable :: whichone
logical,allocatable :: arr(:)
   call set_mode('strict')
   call set_args(' --type run -o F -t F -x F --ox F --xo F --longa:O F --longb:X F')
   whichone=sget('type')
   arr=[lget('o'),lget('t'),lget('x'),lget('ox'),lget('xo'),lget('longa'),lget('longb')]
   select case(whichone)
   case('one')   ; call testit(whichone,.not.any(arr))
   case('two')   ; call testit(whichone,  all(arr))
   case('three') ; call testit(whichone,all(arr.eqv.[T,T,T,F,F,F,F]))
   case('four')  ; call testit(whichone,all(arr.eqv.[F,F,F,T,T,F,F]))
   case('five')  ; call testit(whichone,all(arr.eqv.[T,T,T,F,F,F,F]))
   case('six')   ; call testit(whichone,  all(arr))
   case('run')
      print *,'test_strict: strict mode'
      call runit('--type one ')
      call runit('--type two -ox -t --ox --xo -OX')
      call runit('--type three -tox ')
      call runit('--type four --ox --xo')
      call runit('--type five -t -o -x ')
      call runit('--type six -ox -t --ox --xo --longa --longb')
   case default
      print it,'unknown type'
   end select
contains

subroutine testit(string,test)
character(len=*),intent(in) :: string
logical,intent(in) :: test

   write(*,it,advance='no')arr
   if(test)then
      print it,':strict:',string,'passed'
   else
      print it,':strict:',string,'failed'
      stop 1
   endif

end subroutine testit

subroutine runit(string)
character(len=*),intent(in) :: string
character(len=4096) :: cmd
   call get_command_argument(0,cmd)
   write(stdout,*)'RUN:',trim(cmd)//' '//string
   call execute_command_line(trim(cmd)//' '//string)
end subroutine runit

end program test_strict