Home | History | Annotate | Line # | Download | only in gdb.go
integers.exp revision 1.1
      1  1.1  christos # This testcase is part of GDB, the GNU debugger.
      2  1.1  christos 
      3  1.1  christos # Copyright 2012-2014 Free Software Foundation, Inc.
      4  1.1  christos #
      5  1.1  christos # This program is free software; you can redistribute it and/or modify
      6  1.1  christos # it under the terms of the GNU General Public License as published by
      7  1.1  christos # the Free Software Foundation; either version 3 of the License, or
      8  1.1  christos # (at your option) any later version.
      9  1.1  christos #
     10  1.1  christos # This program is distributed in the hope that it will be useful,
     11  1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  christos # GNU General Public License for more details.
     14  1.1  christos #
     15  1.1  christos # You should have received a copy of the GNU General Public License
     16  1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17  1.1  christos 
     18  1.1  christos # Test integer expressions.
     19  1.1  christos 
     20  1.1  christos load_lib "go.exp"
     21  1.1  christos 
     22  1.1  christos if { [skip_go_tests] } { continue }
     23  1.1  christos 
     24  1.1  christos standard_testfile .go
     25  1.1  christos 
     26  1.1  christos if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } {
     27  1.1  christos     return -1
     28  1.1  christos }
     29  1.1  christos 
     30  1.1  christos set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
     31  1.1  christos set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
     32  1.1  christos 
     33  1.1  christos if { [go_runto_main] < 0 } {
     34  1.1  christos     untested $testfile
     35  1.1  christos     return -1
     36  1.1  christos }
     37  1.1  christos 
     38  1.1  christos if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
     39  1.1  christos     pass "setting breakpoint 1"
     40  1.1  christos }
     41  1.1  christos 
     42  1.1  christos gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
     43  1.1  christos 
     44  1.1  christos gdb_test "print i" ".* = 0" "Print i before assigned to 1"
     45  1.1  christos 
     46  1.1  christos gdb_test "next" "i = 1" "Next to 'i = 1' line"
     47  1.1  christos gdb_test "next" "j = 2" "Next to 'j = 2' line"
     48  1.1  christos # At that point,
     49  1.1  christos # i should be equal to 1
     50  1.1  christos gdb_test "print i" " = 1"
     51  1.1  christos # but j should still be equal to zero
     52  1.1  christos gdb_test "print j" " = 0" "Test j value before assignment"
     53  1.1  christos 
     54  1.1  christos gdb_test "next" "k = 3" "Next to 'k = 3' line"
     55  1.1  christos gdb_test "next" "l = k" "Next to 'l = k' line"
     56  1.1  christos 
     57  1.1  christos #j should be equal to 2
     58  1.1  christos gdb_test "print j" " = 2"
     59  1.1  christos # k should be equal to 3
     60  1.1  christos gdb_test "print k" " = 3"
     61  1.1  christos # But l should still be zero
     62  1.1  christos gdb_test "print l" " = 0"
     63  1.1  christos 
     64  1.1  christos # Test addition
     65  1.1  christos gdb_test "print i + j" " = 3"
     66  1.1  christos gdb_test "print i + k" " = 4"
     67  1.1  christos gdb_test "print j + k" " = 5"
     68  1.1  christos gdb_test "print i + j + k" " = 6"
     69  1.1  christos 
     70  1.1  christos # Test substraction
     71  1.1  christos gdb_test "print j - i" " = 1"
     72  1.1  christos gdb_test "print i - j" "= -1"
     73  1.1  christos gdb_test "print k -i -j" " = 0"
     74  1.1  christos gdb_test "print k -(i + j)" " = 0"
     75  1.1  christos 
     76  1.1  christos # Test unany minus
     77  1.1  christos gdb_test "print -i" " = -1"
     78  1.1  christos gdb_test "print (-i)" " = -1"
     79  1.1  christos gdb_test "print -(i)" " = -1"
     80  1.1  christos gdb_test "print -(i+j)" " = -3"
     81  1.1  christos 
     82  1.1  christos # Test boolean operators =, <>, <, <=, > and >=
     83  1.1  christos gdb_test "print i + 1 == j" " = true"
     84  1.1  christos gdb_test "print i + 1 != j" " = false"
     85  1.1  christos gdb_test "print i + 1 < j" " = false"
     86  1.1  christos gdb_test "print i + 1 <= j" " = true"
     87  1.1  christos gdb_test "print i + 1 > j" " = false"
     88  1.1  christos gdb_test "print i + 1 >= j" " = true"
     89  1.1  christos 
     90  1.1  christos # Test multiplication
     91  1.1  christos gdb_test "print 2 * i" " = 2"
     92  1.1  christos gdb_test "print j * k" " = 6"
     93  1.1  christos gdb_test "print 3000*i" " = 3000"
     94  1.1  christos 
     95  1.1  christos #Test div and mod operators
     96  1.1  christos gdb_test "print 35 / 2" " = 17"
     97  1.1  christos gdb_test "print 35 % 2" " = 1"
     98  1.1  christos 
     99  1.1  christos # Test several operators together
    100  1.1  christos gdb_test "print i+10*j+100*k" " = 321"
    101  1.1  christos gdb_test " print (i + 5) * (j + 7)" " = 54"
    102  1.1  christos 
    103  1.1  christos gdb_test "set var i = 2" " = 2"
    104  1.1  christos gdb_test "print i" " = 2" "Testing new i value"
    105  1.1  christos 
    106  1.1  christos if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
    107  1.1  christos     pass "setting breakpoint 2"
    108  1.1  christos }
    109  1.1  christos 
    110  1.1  christos gdb_test "cont" \
    111  1.1  christos 	 "Breakpoint .*:${bp_location2}.*" \
    112  1.1  christos 	 "Going to second breakpoint"
    113  1.1  christos gdb_test "print i" \
    114  1.1  christos 	 ".* = 5.*" \
    115  1.1  christos 	 "Value of i after assignment"
    116