summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/select_char_1.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/select_char_1.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/select_char_1.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/select_char_1.f9076
1 files changed, 76 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/select_char_1.f90 b/gcc/testsuite/gfortran.dg/select_char_1.f90
new file mode 100644
index 000000000..83c526830
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/select_char_1.f90
@@ -0,0 +1,76 @@
+integer function char_select (s)
+ character(len=*), intent(in) :: s
+
+ select case(s)
+ case ("foo")
+ char_select = 1
+ case ("bar", "gee")
+ char_select = 2
+ case ("111", "999")
+ char_select = 3
+ case ("1024", "1900")
+ char_select = 4
+ case ("12", "17890")
+ char_select = 5
+ case default
+ char_select = -1
+ end select
+end function char_select
+
+integer function char_select2 (s)
+ character(len=*), intent(in) :: s
+
+ char_select2 = -1
+ select case(s)
+ case ("foo")
+ char_select2 = 1
+ case ("bar", "gee")
+ char_select2 = 2
+ case ("111", "999")
+ char_select2 = 3
+ case ("1024", "1900")
+ char_select2 = 4
+ case ("12", "17890")
+ char_select2 = 5
+ end select
+end function char_select2
+
+
+program test
+ interface
+ integer function char_select (s)
+ character(len=*), intent(in) :: s
+ end function char_select
+ integer function char_select2 (s)
+ character(len=*), intent(in) :: s
+ end function char_select2
+ end interface
+
+ if (char_select("foo") /= 1) call abort
+ if (char_select("foo ") /= 1) call abort
+ if (char_select("foo2 ") /= -1) call abort
+ if (char_select("bar") /= 2) call abort
+ if (char_select("gee") /= 2) call abort
+ if (char_select("000") /= -1) call abort
+ if (char_select("101") /= -1) call abort
+ if (char_select("109") /= -1) call abort
+ if (char_select("111") /= 3) call abort
+ if (char_select("254") /= -1) call abort
+ if (char_select("999") /= 3) call abort
+ if (char_select("9989") /= -1) call abort
+ if (char_select("1882") /= -1) call abort
+
+ if (char_select2("foo") /= 1) call abort
+ if (char_select2("foo ") /= 1) call abort
+ if (char_select2("foo2 ") /= -1) call abort
+ if (char_select2("bar") /= 2) call abort
+ if (char_select2("gee") /= 2) call abort
+ if (char_select2("000") /= -1) call abort
+ if (char_select2("101") /= -1) call abort
+ if (char_select2("109") /= -1) call abort
+ if (char_select2("111") /= 3) call abort
+ if (char_select2("254") /= -1) call abort
+ if (char_select2("999") /= 3) call abort
+ if (char_select2("9989") /= -1) call abort
+ if (char_select2("1882") /= -1) call abort
+end program test