]> git.draconx.ca Git - cdecl99.git/blob - tests/internal.at
1ae6f994a78829ae287639325b1eecdade3a0cf5
[cdecl99.git] / tests / internal.at
1 # Copyright © 2021, 2023 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 AT_SETUP([cdecl_declare truncation])
78
79 AT_DATA([input],
80 [[int hello_world
81 int x[1234567890]
82 ]])
83
84 AT_CHECK([rendertest -n 0 <input], [0],
85 [[15 @&t@
86 17 @&t@
87 ]])
88
89 AT_CHECK([rendertest -n 10 <input], [0],
90 [[15 int hello
91 17 int x@<:@123
92 ]])
93
94 AT_CLEANUP
95
96 AT_SETUP([cdecl_explain truncation])
97
98 AT_DATA([input],
99 [[declare x as int
100 type array 123456789 of int
101 ]])
102
103 AT_CHECK([rendertest --english -n 0 <input], [0],
104 [[16 @&t@
105 27 @&t@
106 ]])
107
108 AT_CHECK([rendertest --english -n 15 <input], [0],
109 [[16 declare x as i
110 27 type array 123
111 ]])
112
113 AT_CLEANUP