OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [minmax_char_1.f90] - Blame information for rev 694

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 694 jeremybenn
! Tests for MIN and MAX intrinsics with character arguments
2
!
3
! { dg-do run }
4
program test
5
  character(len=3), parameter :: sp = "gee"
6
  character(len=6), parameter :: tp = "crunch", wp = "flunch"
7
  character(len=2), parameter :: up = "az", vp = "da"
8
 
9
  character(len=3) :: s
10
  character(len=6) :: t, w
11
  character(len=2) :: u, v
12
  s = "gee"
13
  t = "crunch"
14
  u = "az"
15
  v = "da"
16
  w = "flunch"
17
 
18
  if (.not. equal(min("foo", "bar"), "bar")) call abort
19
  if (.not. equal(max("foo", "bar"), "foo")) call abort
20
  if (.not. equal(min("bar", "foo"), "bar")) call abort
21
  if (.not. equal(max("bar", "foo"), "foo")) call abort
22
 
23
  if (.not. equal(min("bar", "foo", sp), "bar")) call abort
24
  if (.not. equal(max("bar", "foo", sp), "gee")) call abort
25
  if (.not. equal(min("bar", sp, "foo"), "bar")) call abort
26
  if (.not. equal(max("bar", sp, "foo"), "gee")) call abort
27
  if (.not. equal(min(sp, "bar", "foo"), "bar")) call abort
28
  if (.not. equal(max(sp, "bar", "foo"), "gee")) call abort
29
 
30
  if (.not. equal(min("foo", "bar", s), "bar")) call abort
31
  if (.not. equal(max("foo", "bar", s), "gee")) call abort
32
  if (.not. equal(min("foo", s, "bar"), "bar")) call abort
33
  if (.not. equal(max("foo", s, "bar"), "gee")) call abort
34
  if (.not. equal(min(s, "foo", "bar"), "bar")) call abort
35
  if (.not. equal(max(s, "foo", "bar"), "gee")) call abort
36
 
37
  if (.not. equal(min("", ""), "")) call abort
38
  if (.not. equal(max("", ""), "")) call abort
39
  if (.not. equal(min("", " "), " ")) call abort
40
  if (.not. equal(max("", " "), " ")) call abort
41
 
42
  if (.not. equal(min(u,v,w), "az    ")) call abort
43
  if (.not. equal(max(u,v,w), "flunch")) call abort
44
  if (.not. equal(min(u,vp,w), "az    ")) call abort
45
  if (.not. equal(max(u,vp,w), "flunch")) call abort
46
  if (.not. equal(min(u,v,wp), "az    ")) call abort
47
  if (.not. equal(max(u,v,wp), "flunch")) call abort
48
  if (.not. equal(min(up,v,w), "az    ")) call abort
49
  if (.not. equal(max(up,v,w), "flunch")) call abort
50
 
51
  call foo("gee   ","az    ",s,t,u,v)
52
  call foo("gee   ","az    ",s,t,u,v)
53
  call foo("gee   ","az    ",s,t,u)
54
  call foo("gee   ","crunch",s,t)
55
 
56
contains
57
 
58
  subroutine foo(res_max, res_min, a, b, c, d)
59
    character(len=*) :: res_min, res_max
60
    character(len=*), optional :: a, b, c, d
61
 
62
    if (.not. equal(min(a,b,c,d), res_min)) call abort
63
    if (.not. equal(max(a,b,c,d), res_max)) call abort
64
  end subroutine foo
65
 
66
  pure function equal(a,b)
67
    character(len=*), intent(in) :: a, b
68
    logical :: equal
69
 
70
    equal = (len(a) == len(b)) .and. (a == b)
71
  end function equal
72
 
73
end program test

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.