Skip to content

Commit dec9bf3

Browse files
committed
Ensure variables can be named 'meta' and 'target'
variables_can_be_named_contextual_keywords tests a bunch of contextual keywords, but not all of them. Include 'meta' and 'target' in the list by reusing the contextual_keywords array in parse-support.h. This commit should not reduce test coverage.
1 parent e550667 commit dec9bf3

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/test-parse-var.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Copyright (C) 2020 Matthew Glazar
22
// See end of file for extended copyright information.
33

4+
#include <algorithm>
45
#include <gmock/gmock.h>
56
#include <gtest/gtest.h>
7+
#include <iterator>
68
#include <quick-lint-js/array.h>
79
#include <quick-lint-js/char8.h>
810
#include <quick-lint-js/cli-location.h>
@@ -1321,9 +1323,17 @@ TEST(test_parse, declare_yield_in_generator_function) {
13211323
}
13221324

13231325
TEST(test_parse, variables_can_be_named_contextual_keywords) {
1324-
for (string8 name :
1325-
{u8"as", u8"async", u8"await", u8"from", u8"get", u8"of", u8"private",
1326-
u8"protected", u8"public", u8"set", u8"static", u8"yield"}) {
1326+
std::vector<const char8*> variable_names;
1327+
std::copy_if(contextual_keywords.begin(), contextual_keywords.end(),
1328+
std::back_inserter(variable_names),
1329+
[](const char8* keyword) { return keyword != u8"let"_sv; });
1330+
variable_names.push_back(u8"await");
1331+
variable_names.push_back(u8"private");
1332+
variable_names.push_back(u8"protected");
1333+
variable_names.push_back(u8"public");
1334+
variable_names.push_back(u8"yield");
1335+
1336+
for (string8 name : variable_names) {
13271337
SCOPED_TRACE(out_string8(name));
13281338

13291339
{

0 commit comments

Comments
 (0)