r174842 - Formatter: Add a test for multi-line ObjC dict literals.
Nico Weber
nicolasweber at gmx.de
Sun Feb 10 12:48:24 PST 2013
Author: nico
Date: Sun Feb 10 14:48:24 2013
New Revision: 174842
URL: http://llvm.org/viewvc/llvm-project?rev=174842&view=rev
Log:
Formatter: Add a test for multi-line ObjC dict literals.
As it turns out, this already works reasonably well.
This example from http://clang.llvm.org/docs/ObjectiveCLiterals.html
NSDictionary *dictionary = @{
@"name" : NSUserName(),
@"date" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo]
};
is formatted like
NSDictionary *dictionary = @{ @"name" : NSUserName(), @"date" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo] };
There's already a FIXME in NestedStaticInitializers about supporting one
initializer per line, which is really all that's missing here too.
Modified:
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=174842&r1=174841&r2=174842&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Feb 10 14:48:24 2013
@@ -2563,6 +2563,9 @@ TEST_F(FormatTest, ObjCLiterals) {
"NSDictionary *settings = @{ AVEncoderKey : @(AVAudioQualityMax) };");
// FIXME: Nested and multi-line array and dictionary literals need more work.
+ verifyFormat(
+ "NSDictionary *d = @{ @\"nam\" : NSUserNam(), @\"dte\" : [NSDate date],\n"
+ " @\"processInfo\" : [NSProcessInfo processInfo] };");
}
TEST_F(FormatTest, ReformatRegionAdjustsIndent) {
More information about the cfe-commits
mailing list