summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran/intrinsics.exp
blob: 2cb0237c9554b7b43c0a77a5c32cc7a59615b31b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright 2019-2020 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 3 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, see <http://www.gnu.org/licenses/>.

# This file tests GDB's handling of Fortran builtin intrinsic functions.

load_lib "fortran.exp"

if { [skip_fortran_tests] } { continue }

standard_testfile .f90

if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] } {
    return -1
}

if { ![fortran_runto_main] } {
    perror "Could not run to main."
    continue
}

gdb_breakpoint [gdb_get_line_number "stop-here"]
gdb_continue_to_breakpoint "stop-here" ".*stop-here.*"

# Test KIND

gdb_test "p kind (l1)" " = 1"
gdb_test "p kind (l2)" " = 2"
gdb_test "p kind (l4)" " = 4"
gdb_test "p kind (l8)" " = 8"
gdb_test "p kind (s1)" "argument to kind must be an intrinsic type"

# Test ABS

gdb_test "p abs (-11)" " = 11"
gdb_test "p abs (11)" " = 11"
# Use `$decimal` to match here as we depend on host floating point
# rounding, which can vary.
gdb_test "p abs (-9.1)" " = 9.$decimal"
gdb_test "p abs (9.1)" " = 9.$decimal"

# Test MOD

gdb_test "p mod (3.0, 2.0)" " = 1"
gdb_test "ptype mod (3.0, 2.0)" "type = real\\*8"
gdb_test "p mod (2.0, 3.0)" " = 2"
gdb_test "p mod (8, 5)" " = 3"
gdb_test "ptype mod (8, 5)" "type = int"
gdb_test "p mod (-8, 5)" " = -3"
gdb_test "p mod (8, -5)" " = 3"
gdb_test "p mod (-8, -5)" " = -3"

# Test CEILING

gdb_test "p ceiling (3.7)" " = 4"
gdb_test "p ceiling (-3.7)" " = -3"

# Test FLOOR

gdb_test "p floor (3.7)" " = 3"
gdb_test "p floor (-3.7)" " = -4"

# Test MODULO

gdb_test "p MODULO (8,5)" " = 3"
gdb_test "ptype MODULO (8,5)" "type = int"
gdb_test "p MODULO (-8,5)" " = 2"
gdb_test "p MODULO (8,-5)" " = -2"
gdb_test "p MODULO (-8,-5)" " = -3"
gdb_test "p MODULO (3.0,2.0)" " = 1"
gdb_test "ptype MODULO (3.0,2.0)" "type = real\\*8"

# Test CMPLX

gdb_test "p CMPLX (4.1, 2.0)" " = \\(4.$decimal,2\\)"