File: repeat_2.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (92 lines) | stat: -rw-r--r-- 2,308 bytes parent folder | download | duplicates (3)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
! REPEAT intrinsic
!
! { dg-do run }
subroutine foo(i, j, s, t)
  implicit none
  integer, intent(in) :: i, j
  character(len=i), intent(in) :: s
  character(len=i*j), intent(in) :: t

  if (repeat(s,j) /= t) STOP 1
  call bar(j,s,t)
end subroutine foo

subroutine bar(j, s, t)
  implicit none
  integer, intent(in) :: j
  character(len=*), intent(in) :: s
  character(len=len(s)*j), intent(in) :: t

  if (repeat(s,j) /= t) STOP 2
end subroutine bar

program test
  implicit none
  character(len=0), parameter :: s0 = "" 
  character(len=1), parameter :: s1 = "a"
  character(len=2), parameter :: s2 = "ab"
  character(len=0) :: t0 
  character(len=1) :: t1
  character(len=2) :: t2
  integer :: i

  t0 = ""
  t1 = "a"
  t2 = "ab"

  if (repeat(t0, 0) /= "") STOP 3
  if (repeat(t1, 0) /= "") STOP 4
  if (repeat(t2, 0) /= "") STOP 5
  if (repeat(t0, 1) /= "") STOP 6
  if (repeat(t1, 1) /= "a") STOP 7
  if (repeat(t2, 1) /= "ab") STOP 8
  if (repeat(t0, 2) /= "") STOP 9
  if (repeat(t1, 2) /= "aa") STOP 10
  if (repeat(t2, 2) /= "abab") STOP 11

  if (repeat(s0, 0) /= "") STOP 12
  if (repeat(s1, 0) /= "") STOP 13
  if (repeat(s2, 0) /= "") STOP 14
  if (repeat(s0, 1) /= "") STOP 15
  if (repeat(s1, 1) /= "a") STOP 16
  if (repeat(s2, 1) /= "ab") STOP 17
  if (repeat(s0, 2) /= "") STOP 18
  if (repeat(s1, 2) /= "aa") STOP 19
  if (repeat(s2, 2) /= "abab") STOP 20

  i = 0
  if (repeat(t0, i) /= "") STOP 21
  if (repeat(t1, i) /= "") STOP 22
  if (repeat(t2, i) /= "") STOP 23
  i = 1
  if (repeat(t0, i) /= "") STOP 24
  if (repeat(t1, i) /= "a") STOP 25
  if (repeat(t2, i) /= "ab") STOP 26
  i = 2
  if (repeat(t0, i) /= "") STOP 27
  if (repeat(t1, i) /= "aa") STOP 28
  if (repeat(t2, i) /= "abab") STOP 29

  i = 0
  if (repeat(s0, i) /= "") STOP 30
  if (repeat(s1, i) /= "") STOP 31
  if (repeat(s2, i) /= "") STOP 32
  i = 1
  if (repeat(s0, i) /= "") STOP 33
  if (repeat(s1, i) /= "a") STOP 34
  if (repeat(s2, i) /= "ab") STOP 35
  i = 2
  if (repeat(s0, i) /= "") STOP 36
  if (repeat(s1, i) /= "aa") STOP 37
  if (repeat(s2, i) /= "abab") STOP 38

  call foo(0,0,"","")
  call foo(0,1,"","")
  call foo(0,2,"","")
  call foo(1,0,"a","")
  call foo(1,1,"a","a")
  call foo(1,2,"a","aa")
  call foo(2,0,"ab","")
  call foo(2,1,"ab","ab")
  call foo(2,2,"ab","abab")
end program test