void UnwrappedLineParser::tryToParseJSFunction() {
nextToken();
+
+ // Consume function name.
+ if (FormatTok->is(tok::identifier))
+ nextToken();
+
if (FormatTok->isNot(tok::l_paren))
return;
nextToken();
"}); // goog.scope");
}
-TEST_F(FormatTestJS, Closures) {
+TEST_F(FormatTestJS, FunctionLiterals) {
verifyFormat("doFoo(function() { return 1; });");
verifyFormat("var func = function() { return 1; };");
verifyFormat("return {\n"
" a: function() { return 1; }\n"
"};",
getGoogleJSStyleWithColumns(37));
+
+ verifyFormat("return {\n"
+ " a: function SomeFunction() {\n"
+ " // ...\n"
+ " return 1;\n"
+ " }\n"
+ "};");
}
TEST_F(FormatTestJS, MultipleFunctionLiterals) {