|
15 | 15 | #include <quick-lint-js/port/char8.h>
|
16 | 16 | #include <vector>
|
17 | 17 |
|
18 |
| -#define DIAG_TYPE_FIELD(diag_type, member, matcher) \ |
19 |
| - ::testing::VariantWith<diag_type>( \ |
20 |
| - ::testing::Field(#member, &diag_type::member, matcher)) |
21 |
| - |
22 |
| -// Equivalent to ::testing::VariantWith<type>(::testing::_), but compiles much |
23 |
| -// more quickly. |
24 |
| -#define DIAG_TYPE(type) \ |
25 |
| - ::quick_lint_js::Diag_Matcher(::quick_lint_js::Diag_Type::type) |
26 |
| - |
27 |
| -// Equivalent to the following, but compiles much more quickly: |
28 |
| -// |
29 |
| -// DIAG_TYPE_FIELD(type, member_0, |
30 |
| -// Offsets_Matcher(code, start_0, end_or_text_0)) |
31 |
| -// |
32 |
| -// but compiles much more quickly. |
33 |
| -#define DIAG_TYPE_OFFSETS(code, type, member_0, start_0, end_or_text_0) \ |
34 |
| - ::quick_lint_js::Diag_Matcher(code, ::quick_lint_js::Diag_Type::type, \ |
35 |
| - ::quick_lint_js::Diag_Matcher::Field{ \ |
36 |
| - DIAG_MATCHER_ARG(type, member_0), \ |
37 |
| - start_0, \ |
38 |
| - end_or_text_0, \ |
39 |
| - }) |
40 |
| - |
41 |
| -// Equivalent to the following, but compiles much more quickly: |
42 |
| -// |
43 |
| -// DIAG_TYPE_FIELD(type, |
44 |
| -// member_0, Offsets_Matcher(code, start_0, end_or_text_0), |
45 |
| -// member_1, Offsets_Matcher(code, start_1, end_or_text_1)) |
46 |
| -#define DIAG_TYPE_2_OFFSETS(code, type, member_0, start_0, end_or_text_0, \ |
47 |
| - member_1, start_1, end_or_text_1) \ |
48 |
| - ::quick_lint_js::Diag_Matcher(code, ::quick_lint_js::Diag_Type::type, \ |
49 |
| - ::quick_lint_js::Diag_Matcher::Field{ \ |
50 |
| - DIAG_MATCHER_ARG(type, member_0), \ |
51 |
| - start_0, \ |
52 |
| - end_or_text_0, \ |
53 |
| - }, \ |
54 |
| - ::quick_lint_js::Diag_Matcher::Field{ \ |
55 |
| - DIAG_MATCHER_ARG(type, member_1), \ |
56 |
| - start_1, \ |
57 |
| - end_or_text_1, \ |
58 |
| - }) |
59 |
| - |
60 |
| -// Equivalent to the following, but compiles much more quickly: |
61 |
| -// |
62 |
| -// DIAG_TYPE_FIELD(type, member_0, source_code_span_matcher(span_0)) |
63 |
| -// |
64 |
| -// but compiles much more quickly. |
65 |
| -#define DIAG_TYPE_SPAN(type, member_0, span_0) \ |
66 |
| - ::quick_lint_js::Diag_Spans_Matcher( \ |
67 |
| - ::quick_lint_js::Diag_Type::type, \ |
68 |
| - ::quick_lint_js::Diag_Spans_Matcher::Field{ \ |
69 |
| - DIAG_MATCHER_ARG(type, member_0), \ |
70 |
| - span_0, \ |
71 |
| - }) |
72 |
| - |
73 |
| -// Equivalent to the following, but compiles much more quickly: |
74 |
| -// |
75 |
| -// DIAG_TYPE_2_FIELD(type, |
76 |
| -// member_0, source_code_span_matcher(span_0), |
77 |
| -// member_1, source_code_span_matcher(span_1)) |
78 |
| -// |
79 |
| -// but compiles much more quickly. |
80 |
| -#define DIAG_TYPE_2_SPANS(type, member_0, span_0, member_1, span_1) \ |
81 |
| - ::quick_lint_js::Diag_Spans_Matcher( \ |
82 |
| - ::quick_lint_js::Diag_Type::type, \ |
83 |
| - ::quick_lint_js::Diag_Spans_Matcher::Field{ \ |
84 |
| - DIAG_MATCHER_ARG(type, member_0), \ |
85 |
| - span_0, \ |
86 |
| - }, \ |
87 |
| - ::quick_lint_js::Diag_Spans_Matcher::Field{ \ |
88 |
| - DIAG_MATCHER_ARG(type, member_1), \ |
89 |
| - span_1, \ |
90 |
| - }) |
91 |
| - |
92 | 18 | namespace quick_lint_js {
|
93 |
| -class Offsets_Matcher { |
94 |
| - public: |
95 |
| - // Create an Offsets_Matcher which asserts that the matched Source_Code_Span |
96 |
| - // begins at begin_offset and ends at end_offset. |
97 |
| - explicit Offsets_Matcher(Padded_String_View input, |
98 |
| - CLI_Source_Position::Offset_Type begin_offset, |
99 |
| - CLI_Source_Position::Offset_Type end_offset); |
100 |
| - |
101 |
| - // Create an Offsets_Matcher which asserts that the matched Source_Code_Span |
102 |
| - // begins at begin_offset and ends at begin_offset+strlen(text). |
103 |
| - // |
104 |
| - // TODO(strager): Also ensure the matched Source_Code_Span's content equals |
105 |
| - // text. |
106 |
| - explicit Offsets_Matcher(Padded_String_View input, |
107 |
| - CLI_Source_Position::Offset_Type begin_offset, |
108 |
| - String8_View text); |
109 |
| - |
110 |
| - Offsets_Matcher(const Offsets_Matcher &) = delete; |
111 |
| - Offsets_Matcher &operator=(const Offsets_Matcher &) = delete; |
112 |
| - |
113 |
| - Offsets_Matcher(Offsets_Matcher &&); |
114 |
| - Offsets_Matcher &operator=(Offsets_Matcher &&); |
115 |
| - |
116 |
| - ~Offsets_Matcher(); |
117 |
| - |
118 |
| - /*implicit*/ operator testing::Matcher<const Source_Code_Span &>() const; |
119 |
| - |
120 |
| - private: |
121 |
| - class Span_Impl; |
122 |
| - |
123 |
| - Padded_String_View code_; |
124 |
| - CLI_Source_Position::Offset_Type begin_offset_; |
125 |
| - CLI_Source_Position::Offset_Type end_offset_; |
126 |
| -}; |
127 |
| - |
128 | 19 | // Metadata for a member of a diagnostic class.
|
129 | 20 | struct Diag_Matcher_Arg {
|
130 | 21 | std::string_view member_name;
|
@@ -160,52 +51,6 @@ struct Diag_Matcher_Arg {
|
160 | 51 | type::member)>(), \
|
161 | 52 | })
|
162 | 53 |
|
163 |
| -// A mix of ::testing::VariantWith, ::testing::Field, and Offsets_Matcher. These |
164 |
| -// are combined into one matcher to significantly reduce compile times. |
165 |
| -// |
166 |
| -// See DIAG_TYPE and DIAG_TYPE_OFFSETS for example usage. |
167 |
| -class Diag_Matcher { |
168 |
| - public: |
169 |
| - struct Field { |
170 |
| - // Must be Source_Code_Span. |
171 |
| - Diag_Matcher_Arg arg; |
172 |
| - |
173 |
| - CLI_Source_Position::Offset_Type begin_offset; |
174 |
| - String8_View text; |
175 |
| - }; |
176 |
| - |
177 |
| - explicit Diag_Matcher(Diag_Type type); |
178 |
| - |
179 |
| - // Create an Offsets_Matcher which asserts that an error's Source_Code_Span |
180 |
| - // begins at field.begin_offset and ends at |
181 |
| - // field.begin_offset+strlen(field.text). |
182 |
| - // |
183 |
| - // TODO(strager): Also ensure the error's Source_Code_Span's content equals |
184 |
| - // text. |
185 |
| - explicit Diag_Matcher(Padded_String_View input, Diag_Type type, Field); |
186 |
| - explicit Diag_Matcher(Padded_String_View input, Diag_Type type, Field, Field); |
187 |
| - explicit Diag_Matcher(Padded_String_View input, Diag_Type type, Field, Field, |
188 |
| - Field); |
189 |
| - |
190 |
| - Diag_Matcher(const Diag_Matcher &) = default; |
191 |
| - Diag_Matcher(Diag_Matcher &&) = default; |
192 |
| - Diag_Matcher &operator=(const Diag_Matcher &) = default; |
193 |
| - Diag_Matcher &operator=(Diag_Matcher &&) = default; |
194 |
| - |
195 |
| - /*implicit*/ operator testing::Matcher<const Diag_Collector::Diag &>() const; |
196 |
| - |
197 |
| - private: |
198 |
| - class Impl; |
199 |
| - |
200 |
| - struct State { |
201 |
| - Diag_Type type; |
202 |
| - std::optional<Padded_String_View> input; |
203 |
| - std::vector<Field> fields; |
204 |
| - }; |
205 |
| - |
206 |
| - State state_; |
207 |
| -}; |
208 |
| - |
209 | 54 | struct Any_Diag_Pointer {
|
210 | 55 | Diag_Type type;
|
211 | 56 | const void *data;
|
@@ -260,43 +105,6 @@ class Diag_Matcher_2 {
|
260 | 105 |
|
261 | 106 | State state_;
|
262 | 107 | };
|
263 |
| - |
264 |
| -// A mix of ::testing::VariantWith, ::testing::Field, and |
265 |
| -// source_code_span_matcher. These are combined into one matcher to |
266 |
| -// significantly reduce compile times. |
267 |
| -// |
268 |
| -// See DIAG_TYPE_SPAN for example usage. |
269 |
| -class Diag_Spans_Matcher { |
270 |
| - public: |
271 |
| - struct Field { |
272 |
| - // Must be Source_Code_Span. |
273 |
| - Diag_Matcher_Arg arg; |
274 |
| - |
275 |
| - Source_Code_Span expected; |
276 |
| - }; |
277 |
| - |
278 |
| - // Create a matcher which asserts that an error's Source_Code_Span's |
279 |
| - // begin and end pointers equal the expected span. |
280 |
| - explicit Diag_Spans_Matcher(Diag_Type type, Field); |
281 |
| - explicit Diag_Spans_Matcher(Diag_Type type, Field, Field); |
282 |
| - |
283 |
| - Diag_Spans_Matcher(const Diag_Spans_Matcher &) = default; |
284 |
| - Diag_Spans_Matcher(Diag_Spans_Matcher &&) = default; |
285 |
| - Diag_Spans_Matcher &operator=(const Diag_Spans_Matcher &) = default; |
286 |
| - Diag_Spans_Matcher &operator=(Diag_Spans_Matcher &&) = default; |
287 |
| - |
288 |
| - /*implicit*/ operator testing::Matcher<const Diag_Collector::Diag &>() const; |
289 |
| - |
290 |
| - private: |
291 |
| - class Impl; |
292 |
| - |
293 |
| - struct State { |
294 |
| - Diag_Type type; |
295 |
| - std::vector<Field> fields; |
296 |
| - }; |
297 |
| - |
298 |
| - State state_; |
299 |
| -}; |
300 | 108 | }
|
301 | 109 |
|
302 | 110 | // quick-lint-js finds bugs in JavaScript programs.
|
|
0 commit comments