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