diff options
author | Wu Zhou <woodzltc@cn.ibm.com> | 2005-09-20 06:37:03 +0000 |
---|---|---|
committer | Wu Zhou <woodzltc@cn.ibm.com> | 2005-09-20 06:37:03 +0000 |
commit | ca9295176c78c61895933517fcb2c73efa093a0a (patch) | |
tree | 483ce5ebaa95e7e30b1bfd8cc03cc69c3973afbd /gdb/testsuite | |
parent | c3e308a89cc880badddebbeecec0d240f2728b6d (diff) | |
download | gdb-ca9295176c78c61895933517fcb2c73efa093a0a.zip gdb-ca9295176c78c61895933517fcb2c73efa093a0a.tar.gz gdb-ca9295176c78c61895933517fcb2c73efa093a0a.tar.bz2 |
* gdb.fortran/subarray.exp: New testcase to test the evaluation
of subarray and substring variable.
* gdb.fortran/subarray.f: New source file for the test of subarray
and substring variable evaluation.
* gdb.fortran/exprs.exp: Add four tests for substring evaluation
of string constant.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.fortran/exprs.exp | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.fortran/subarray.exp | 66 | ||||
-rw-r--r-- | gdb/testsuite/gdb.fortran/subarray.f | 36 |
4 files changed, 118 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d4d268a..e791be2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2005-09-20 Wu Zhou <woodzltc@cn.ibm.com> + + * gdb.fortran/subarray.exp: New testcase to test the evaluation + of subarray and substring variable. + * gdb.fortran/subarray.f: New source file for the test of subarray + and substring variable evaluation. + * gdb.fortran/exprs.exp: Add four tests for substring evaluation + of string constant. + 2005-09-19 Daniel Jacobowitz <dan@codesourcery.com> * gdb.arch/altivec-regs.exp, gdb.arch/altivec-abi.exp: Update diff --git a/gdb/testsuite/gdb.fortran/exprs.exp b/gdb/testsuite/gdb.fortran/exprs.exp index c970399..3f8d508 100644 --- a/gdb/testsuite/gdb.fortran/exprs.exp +++ b/gdb/testsuite/gdb.fortran/exprs.exp @@ -59,6 +59,13 @@ proc test_character_literals_accepted {} { # Test various character values. gdb_test "p 'a'" " = 'a'" + + # Test various substring expression. + gdb_test "p 'abcdefg'(2:4)" " = 'bcd'" + gdb_test "p 'abcdefg'(:3)" " = 'abc'" + gdb_test "p 'abcdefg'(5:)" " = 'efg'" + gdb_test "p 'abcdefg'(:)" " = 'abcdefg'" + } proc test_integer_literals_rejected {} { @@ -248,8 +255,6 @@ proc test_arithmetic_expressions {} { gdb_test "p 6.0 / 3" " = 2" "real divided by int" gdb_test "p 6.0 / 3.0" " = 2" "real divided by real" - # Test modulo with various operands - # Test exponentiation with various operands gdb_test "p 2 ** 3" " = 8" "int powered by int" diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp new file mode 100644 index 0000000..b93a6b7 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/subarray.exp @@ -0,0 +1,66 @@ +# Copyright 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was written by Wu Zhou. (woodzltc@cn.ibm.com) + +# This file is part of the gdb testsuite. It contains tests for evaluating +# Fortran subarray expression. + +if $tracelevel then { + strace $tracelevel +} + +set testfile "subarray" +set srcfile ${testfile}.f +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto MAIN__] then { + perror "couldn't run to breakpoint MAIN__" + continue +} + +# Try to set breakpoint at the last write statement. + +set bp_location [gdb_get_line_number "str(:)"] +gdb_test "break $bp_location" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location\\." \ + "breakpoint at the last write statement" +gdb_test "continue" \ + "Continuing\\..*Breakpoint.*" \ + "continue to breakpoint" + +# Test four different kinds of subarray expression evaluation. + +gdb_test "print str(2:4)" ".*1 = \\(98 'b', 99 'c', 100 'd'\\).*" "print str(2:4)" +gdb_test "print str(:3)" ".*2 = \\(97 'a', 98 'b', 99 'c'\\).*" "print str(:3)" +gdb_test "print str(5:)" ".*3 = \\(101 'e', 102 'f', 103 'g'\\).*" "print str(5:)" +gdb_test "print str(:)" ".*4 = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\).*" "print str(:)" + +gdb_test "print array(2:4)" ".*5 = \\(2, 3, 4\\).*" "print array(2:4)" +gdb_test "print array(:3)" ".*6 = \\(1, 2, 3\\).*" "print array(:3)" +gdb_test "print array(5:)" ".*7 = \\(5, 6, 7\\).*" "print array(5:)" +gdb_test "print array(:)" ".*8 = \\(1, 2, 3, 4, 5, 6, 7\\).*" "print array(:)" + diff --git a/gdb/testsuite/gdb.fortran/subarray.f b/gdb/testsuite/gdb.fortran/subarray.f new file mode 100644 index 0000000..ee91c9a --- /dev/null +++ b/gdb/testsuite/gdb.fortran/subarray.f @@ -0,0 +1,36 @@ +c Copyright 2005 Free Software Foundation, Inc. + +c This program is free software; you can redistribute it and/or modify +c it under the terms of the GNU General Public License as published by +c the Free Software Foundation; either version 2 of the License, or +c (at your option) any later version. +c +c This program is distributed in the hope that it will be useful, +c but WITHOUT ANY WARRANTY; without even the implied warranty of +c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +c GNU General Public License for more details. +c +c You should have received a copy of the GNU General Public License +c along with this program; if not, write to the Free Software +c Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +c Ihis file is the Fortran source file for subarray.exp. It was written +c by Wu Zhou. (woodzltc@cn.ibm.com) + + PROGRAM subarray + + character *7 str + integer array(7) + +c Initialize character array "str" and integer array "array". + str = 'abcdefg' + do i = 1, 7 + array(i) = i + end do + + write (*, *) str(2:4) + write (*, *) str(:3) + write (*, *) str(5:) + write (*, *) str(:) + + END PROGRAM |