]> granicus.if.org Git - clang/blobdiff - unittests/Format/FormatTestJS.cpp
clang-format: [JS] Properly set scopes inside template strings.
[clang] / unittests / Format / FormatTestJS.cpp
index 71821a06499d357170c78f521f1516b1cd5845a9..6cc3bcd16c466aaeabc7c187692e264e8f4257c7 100644 (file)
@@ -1392,6 +1392,13 @@ TEST_F(FormatTestJS, TemplateStrings) {
   // The token stream can contain two string_literals in sequence, but that
   // doesn't mean that they are implicitly concatenated in JavaScript.
   verifyFormat("var f = `aaaa ${a ? 'a' : 'b'}`;");
+
+  // Ensure that scopes are appropriately set around evaluated expressions in
+  // template strings.
+  verifyFormat("var f = `aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa\n"
+               "         aaaaaaaaaaaaa:${aaaaaaa.aaaaa} aaaaaaaa`;",
+               "var f = `aaaaaaaaaaaaa:${aaaaaaa.  aaaaa} aaaaaaaa\n"
+               "         aaaaaaaaaaaaa:${  aaaaaaa. aaaaa} aaaaaaaa`;");
 }
 
 TEST_F(FormatTestJS, TemplateStringASI) {