clang-format: [JS] Support shebang lines on the very first line.
Summary:
Shebang lines (`#!/bin/blah`) can be used in JavaScript scripts to indicate
they should be run using e.g. node. This change treats # lines on the first line
as line comments.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20632
llvm-svn: 271185
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 33fd065..e956ae2 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1276,5 +1276,12 @@
verifyFormat("var x = 'foo';", LeaveQuotes);
}
+TEST_F(FormatTestJS, SupportShebangLines) {
+ verifyFormat("#!/usr/bin/env node\n"
+ "var x = hello();",
+ "#!/usr/bin/env node\n"
+ "var x = hello();");
+}
+
} // end namespace tooling
} // end namespace clang