Skip to content

Commit 451d434

Browse files
committed
refactor: rename error_matcher -> diag_matcher
1 parent 26311f5 commit 451d434

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

test/error-matcher.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ span_matcher::operator testing::Matcher<const source_code_span &>() const {
165165
new span_impl(this->expected_));
166166
}
167167

168-
source_code_span error_matcher::field::get_span(const void *error_object) const
168+
source_code_span diag_matcher::field::get_span(const void *error_object) const
169169
noexcept {
170170
const void *member_data =
171171
reinterpret_cast<const char *>(error_object) + this->member_offset;
@@ -178,21 +178,21 @@ source_code_span error_matcher::field::get_span(const void *error_object) const
178178
QLJS_UNREACHABLE();
179179
}
180180

181-
error_matcher::error_matcher(diag_type type) : state_{type, std::nullopt, {}} {}
181+
diag_matcher::diag_matcher(diag_type type) : state_{type, std::nullopt, {}} {}
182182

183-
error_matcher::error_matcher(padded_string_view input, diag_type type,
184-
field field_0)
183+
diag_matcher::diag_matcher(padded_string_view input, diag_type type,
184+
field field_0)
185185
: state_{type, input, {field_0}} {}
186186

187-
error_matcher::error_matcher(padded_string_view input, diag_type type,
188-
field field_0, field field_1)
187+
diag_matcher::diag_matcher(padded_string_view input, diag_type type,
188+
field field_0, field field_1)
189189
: state_{type, input, {field_0, field_1}} {}
190190

191-
error_matcher::error_matcher(padded_string_view input, diag_type type,
192-
field field_0, field field_1, field field_2)
191+
diag_matcher::diag_matcher(padded_string_view input, diag_type type,
192+
field field_0, field field_1, field field_2)
193193
: state_{type, input, {field_0, field_1, field_2}} {}
194194

195-
class error_matcher::impl
195+
class diag_matcher::impl
196196
: public testing::MatcherInterface<const diag_collector::diag &> {
197197
public:
198198
explicit impl(state s) : state_(std::move(s)) {}
@@ -250,7 +250,7 @@ class error_matcher::impl
250250
state state_;
251251
};
252252

253-
/*implicit*/ error_matcher::operator testing::Matcher<
253+
/*implicit*/ diag_matcher::operator testing::Matcher<
254254
const diag_collector::diag &>() const {
255255
return testing::Matcher<const diag_collector::diag &>(new impl(this->state_));
256256
}

test/quick-lint-js/error-matcher.h

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// Equivalent to ::testing::VariantWith<type>(::testing::_), but compiles much
3737
// more quickly.
3838
#define ERROR_TYPE(type) \
39-
::quick_lint_js::error_matcher(::quick_lint_js::diag_type::type)
39+
::quick_lint_js::diag_matcher(::quick_lint_js::diag_type::type)
4040

4141
// Equivalent to the following, but compiles much more quickly:
4242
//
@@ -45,9 +45,9 @@
4545
//
4646
// but compiles much more quickly.
4747
#define ERROR_TYPE_OFFSETS(code, type, member_0, start_0, end_or_text_0) \
48-
::quick_lint_js::error_matcher( \
48+
::quick_lint_js::diag_matcher( \
4949
code, ::quick_lint_js::diag_type::type, \
50-
::quick_lint_js::error_matcher::field{ \
50+
::quick_lint_js::diag_matcher::field{ \
5151
#member_0, \
5252
offsetof(type, member_0), \
5353
::quick_lint_js::get_error_matcher_field_type<decltype( \
@@ -63,17 +63,17 @@
6363
// member_1, offsets_matcher(code, start_1, end_or_text_1))
6464
#define ERROR_TYPE_2_OFFSETS(code, type, member_0, start_0, end_or_text_0, \
6565
member_1, start_1, end_or_text_1) \
66-
::quick_lint_js::error_matcher( \
66+
::quick_lint_js::diag_matcher( \
6767
code, ::quick_lint_js::diag_type::type, \
68-
::quick_lint_js::error_matcher::field{ \
68+
::quick_lint_js::diag_matcher::field{ \
6969
#member_0, \
7070
offsetof(type, member_0), \
7171
::quick_lint_js::get_error_matcher_field_type<decltype( \
7272
type::member_0)>(), \
7373
start_0, \
7474
end_or_text_0, \
7575
}, \
76-
::quick_lint_js::error_matcher::field{ \
76+
::quick_lint_js::diag_matcher::field{ \
7777
#member_1, \
7878
offsetof(type, member_1), \
7979
::quick_lint_js::get_error_matcher_field_type<decltype( \
@@ -91,25 +91,25 @@
9191
#define ERROR_TYPE_3_OFFSETS(code, type, member_0, start_0, end_or_text_0, \
9292
member_1, start_1, end_or_text_1, member_2, \
9393
start_2, end_or_text_2) \
94-
::quick_lint_js::error_matcher( \
94+
::quick_lint_js::diag_matcher( \
9595
code, ::quick_lint_js::diag_type::type, \
96-
::quick_lint_js::error_matcher::field{ \
96+
::quick_lint_js::diag_matcher::field{ \
9797
#member_0, \
9898
offsetof(type, member_0), \
9999
::quick_lint_js::get_error_matcher_field_type<decltype( \
100100
type::member_0)>(), \
101101
start_0, \
102102
end_or_text_0, \
103103
}, \
104-
::quick_lint_js::error_matcher::field{ \
104+
::quick_lint_js::diag_matcher::field{ \
105105
#member_1, \
106106
offsetof(type, member_1), \
107107
::quick_lint_js::get_error_matcher_field_type<decltype( \
108108
type::member_1)>(), \
109109
start_1, \
110110
end_or_text_1, \
111111
}, \
112-
::quick_lint_js::error_matcher::field{ \
112+
::quick_lint_js::diag_matcher::field{ \
113113
#member_2, \
114114
offsetof(type, member_2), \
115115
::quick_lint_js::get_error_matcher_field_type<decltype( \
@@ -171,7 +171,7 @@ class span_matcher {
171171
// are combined into one matcher to significantly reduce compile times.
172172
//
173173
// See ERROR_TYPE and ERROR_TYPE_OFFSETS for example usage.
174-
class error_matcher {
174+
class diag_matcher {
175175
public:
176176
enum class field_type {
177177
identifier,
@@ -189,24 +189,23 @@ class error_matcher {
189189
source_code_span get_span(const void *error_object) const noexcept;
190190
};
191191

192-
explicit error_matcher(diag_type type);
192+
explicit diag_matcher(diag_type type);
193193

194194
// Create an offsets_matcher which asserts that an error's source_code_span
195195
// begins at field.begin_offset and ends at
196196
// field.begin_offset+strlen(field.text).
197197
//
198198
// TODO(strager): Also ensure the error's source_code_span's content equals
199199
// text.
200-
explicit error_matcher(padded_string_view input, diag_type type, field);
201-
explicit error_matcher(padded_string_view input, diag_type type, field,
202-
field);
203-
explicit error_matcher(padded_string_view input, diag_type type, field, field,
204-
field);
200+
explicit diag_matcher(padded_string_view input, diag_type type, field);
201+
explicit diag_matcher(padded_string_view input, diag_type type, field, field);
202+
explicit diag_matcher(padded_string_view input, diag_type type, field, field,
203+
field);
205204

206-
error_matcher(const error_matcher &) = default;
207-
error_matcher(error_matcher &&) = default;
208-
error_matcher &operator=(const error_matcher &) = default;
209-
error_matcher &operator=(error_matcher &&) = default;
205+
diag_matcher(const diag_matcher &) = default;
206+
diag_matcher(diag_matcher &&) = default;
207+
diag_matcher &operator=(const diag_matcher &) = default;
208+
diag_matcher &operator=(diag_matcher &&) = default;
210209

211210
/*implicit*/ operator testing::Matcher<const diag_collector::diag &>() const;
212211

@@ -224,17 +223,17 @@ class error_matcher {
224223

225224
// Internal helper for ERROR_TYPE_OFFSETS macros.
226225
template <class>
227-
constexpr error_matcher::field_type get_error_matcher_field_type() noexcept =
226+
constexpr diag_matcher::field_type get_error_matcher_field_type() noexcept =
228227
delete;
229228
template <>
230-
constexpr error_matcher::field_type
229+
constexpr diag_matcher::field_type
231230
get_error_matcher_field_type<identifier>() noexcept {
232-
return error_matcher::field_type::identifier;
231+
return diag_matcher::field_type::identifier;
233232
}
234233
template <>
235-
constexpr error_matcher::field_type
234+
constexpr diag_matcher::field_type
236235
get_error_matcher_field_type<source_code_span>() noexcept {
237-
return error_matcher::field_type::source_code_span;
236+
return diag_matcher::field_type::source_code_span;
238237
}
239238
}
240239

test/test-error-matcher.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::string get_matcher_message(::testing::Matcher<const Value &> matcher,
2626
return listener.str();
2727
}
2828

29-
TEST(test_error_matcher, match_error_type) {
29+
TEST(test_diag_matcher, match_error_type) {
3030
padded_string code(u8"hello"_sv);
3131

3232
::testing::Matcher<const diag_collector::diag &> continue_matcher =
@@ -49,7 +49,7 @@ TEST(test_error_matcher, match_error_type) {
4949
})));
5050
}
5151

52-
TEST(test_error_matcher, match_error_type_message) {
52+
TEST(test_diag_matcher, match_error_type_message) {
5353
padded_string code(u8"hello"_sv);
5454
::testing::Matcher<const diag_collector::diag &> matcher =
5555
ERROR_TYPE(diag_invalid_break);
@@ -60,7 +60,7 @@ TEST(test_error_matcher, match_error_type_message) {
6060
"whose type (diag_invalid_continue) isn't diag_invalid_break");
6161
}
6262

63-
TEST(test_error_matcher, match_error_type_with_1_field) {
63+
TEST(test_diag_matcher, match_error_type_with_1_field) {
6464
padded_string code(u8"hello"_sv);
6565

6666
::testing::Matcher<const diag_collector::diag &> continue_matcher =
@@ -85,7 +85,7 @@ TEST(test_error_matcher, match_error_type_with_1_field) {
8585
})));
8686
}
8787

88-
TEST(test_error_matcher, match_error_type_with_1_field_message) {
88+
TEST(test_diag_matcher, match_error_type_with_1_field_message) {
8989
padded_string code(u8"hello"_sv);
9090
::testing::Matcher<const diag_collector::diag &> matcher =
9191
ERROR_TYPE_OFFSETS(&code, diag_invalid_continue, //
@@ -97,7 +97,7 @@ TEST(test_error_matcher, match_error_type_with_1_field_message) {
9797
"whose type (diag_invalid_break) isn't diag_invalid_continue");
9898
}
9999

100-
TEST(test_error_matcher, match_offsets_of_1_field_span) {
100+
TEST(test_diag_matcher, match_offsets_of_1_field_span) {
101101
padded_string code(u8"hello"_sv);
102102

103103
::testing::Matcher<const diag_collector::diag &> continue_matcher =
@@ -117,7 +117,7 @@ TEST(test_error_matcher, match_offsets_of_1_field_span) {
117117
})));
118118
}
119119

120-
TEST(test_error_matcher, match_offsets_of_1_field_identifier) {
120+
TEST(test_diag_matcher, match_offsets_of_1_field_identifier) {
121121
padded_string code(u8"hello"_sv);
122122

123123
::testing::Matcher<const diag_collector::diag &> matcher =
@@ -137,7 +137,7 @@ TEST(test_error_matcher, match_offsets_of_1_field_identifier) {
137137
})));
138138
}
139139

140-
TEST(test_error_matcher, match_offsets_of_1_field_message) {
140+
TEST(test_diag_matcher, match_offsets_of_1_field_message) {
141141
padded_string code(u8"hello"_sv);
142142
{
143143
::testing::Matcher<const diag_collector::diag &> matcher =
@@ -162,7 +162,7 @@ TEST(test_error_matcher, match_offsets_of_1_field_message) {
162162
}
163163
}
164164

165-
TEST(test_error_matcher, match_offsets_of_2_fields_span) {
165+
TEST(test_diag_matcher, match_offsets_of_2_fields_span) {
166166
padded_string code(u8"...x,"_sv);
167167

168168
::testing::Matcher<const diag_collector::diag &> matcher =
@@ -189,7 +189,7 @@ TEST(test_error_matcher, match_offsets_of_2_fields_span) {
189189
<< "when second doesn't match";
190190
}
191191

192-
TEST(test_error_matcher, match_offsets_of_2_fields_message) {
192+
TEST(test_diag_matcher, match_offsets_of_2_fields_message) {
193193
padded_string code(u8"...x,"_sv);
194194

195195
// Two wrong fields:

0 commit comments

Comments
 (0)