diff options
author | Daniel Jasper <djasper@google.com> | 2015-09-28 14:29:45 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-09-28 14:29:45 +0000 |
commit | ba52fcb7d519e6a9a8cefa578c28c867db12260e (patch) | |
tree | fb6b05ad81d9daab807a2f1119e054e83f782bf9 /clang/unittests/Format/FormatTestJS.cpp | |
parent | 9f642f7d7aeefd4ce676c891ea462c0f32a5ed68 (diff) | |
download | bcm5719-llvm-ba52fcb7d519e6a9a8cefa578c28c867db12260e.tar.gz bcm5719-llvm-ba52fcb7d519e6a9a8cefa578c28c867db12260e.zip |
clang-format: [JS] Support pseudo-keywords
JavaScript allows keywords to appear in IdenfierName positions, e.g.
fields, or object literal members, but not as plain identifiers.
Patch by Martin Probst. Thank you!
llvm-svn: 248714
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index c02d51be505..f09df281429 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -99,6 +99,19 @@ TEST_F(FormatTestJS, LiteralOperatorsCanBeKeywords) { verifyFormat("not.and.or.not_eq = 1;"); } +TEST_F(FormatTestJS, ReservedWords) { + // JavaScript reserved words (aka keywords) are only illegal when used as + // Identifiers, but are legal as IdentifierNames. + verifyFormat("x.class.struct = 1;"); + verifyFormat("x.case = 1;"); + verifyFormat("x.interface = 1;"); + verifyFormat("x = {\n" + " a: 12,\n" + " interface: 1,\n" + " switch: 1,\n" + "};"); +} + TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); verifyFormat("let [a, b, c] = [1, 2, 3];"); |