]> git.draconx.ca Git - cdecl99.git/blob - tests/internal.at
Release 1.3.
[cdecl99.git] / tests / internal.at
1 # Copyright © 2021, 2023-2024 Nick Bowler
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
15
16 AT_BANNER([Internal library behaviour])
17
18 AT_SETUP([cdecl__normalize_specs])
19 AT_KEYWORDS([libcdecl internal])
20
21 TEST_NEED_PROGRAM([normalize])
22
23 # Note that not all combinations of specifiers make a specifier list that can
24 # appear in a valid C declaration.  We don't want to test normalization of
25 # invalid specifier lists: each line in the below input file is a specifier
26 # list that is possible to use.
27 AT_DATA([input],
28 [[int long signed long
29 long int long unsigned
30 short signed int
31 int short unsigned
32 char signed
33 char unsigned
34 _Complex float
35 _Imaginary float
36 _Imaginary double long
37 long _Complex double
38
39 const struct foo volatile restrict restrict const volatile const restrict
40 volatile const const restrict union bar restrict volatile volatile const
41 const const volatile volatile restrict restrict volatile enum baz volatile
42
43 int signed long const volatile inline static
44 short inline int extern volatile unsigned const
45 _Complex volatile double const long typedef
46 long const _Imaginary double register volatile
47 volatile _Bool const auto
48 ]])
49
50 AT_CHECK([normalize -f input], [0], [[signed long long int
51 unsigned long long int
52 signed short int
53 unsigned short int
54 signed char
55 unsigned char
56 float _Complex
57 float _Imaginary
58 long double _Imaginary
59 long double _Complex
60
61 restrict volatile const struct foo
62 restrict volatile const union bar
63 restrict volatile const enum baz
64
65 static inline volatile const signed long int
66 extern inline volatile const unsigned short int
67 typedef volatile const long double _Complex
68 register volatile const long double _Imaginary
69 auto volatile const _Bool
70 ]])
71
72 AT_CLEANUP
73
74 TEST_TAP_SIMPLE([cdecl__err sanity], [cdeclerr],
75   [TEST_NEED_PROGRAM([cdeclerr])], [libcdecl internal])
76
77 TEST_TAP_SIMPLE([cdecl__err thread safety], [errthread],
78   [TEST_NEED_PROGRAM([errthread])], [libcdecl internal threads])
79
80 AT_SETUP([cdecl_declare truncation])
81 AT_KEYWORDS([libcdecl internal])
82
83 AT_DATA([input],
84 [[int hello_world
85 int x[1234567890]
86 ]])
87
88 AT_CHECK([rendertest -n 0 <input], [0],
89 [[15
90 17
91 ]])
92
93 AT_CHECK([rendertest -n 10 <input], [0],
94 [[15 int hello
95 17 int x@<:@123
96 ]])
97
98 AT_CLEANUP
99
100 AT_SETUP([cdecl_explain truncation])
101 AT_KEYWORDS([libcdecl internal])
102
103 AT_DATA([input],
104 [[declare x as int
105 type array 123456789 of int
106 ]])
107
108 AT_CHECK([rendertest --english -n 0 <input], [0],
109 [[16
110 27
111 ]])
112
113 AT_CHECK([rendertest --english -n 15 <input], [0],
114 [[16 declare x as i
115 27 type array 123
116 ]])
117
118 AT_CLEANUP
119
120 AT_SETUP([cdecl__yylex integer constants])
121
122 AT_CHECK([scantest \
123   '0 000 0x00 0X00' \
124   '1234 01234 0x1234 0X1234' \
125   '4294967295 037777777777 0xffffffff 0XFFFFFFFF' \
126   09 012345678 0x 0X], [0],
127 [[integer constant 0
128 integer constant 0
129 integer constant 0
130 integer constant 0
131 eof
132 integer constant 1234
133 integer constant 668
134 integer constant 4660
135 integer constant 4660
136 eof
137 integer constant 4294967295
138 integer constant 4294967295
139 integer constant 4294967295
140 integer constant 4294967295
141 eof
142 @@@
143 eof
144 @@@
145 eof
146 @@@
147 eof
148 @@@
149 eof
150 ]])
151
152 AT_CLEANUP