summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-03-31 14:34:15 +0000
committerDaniel Jasper <djasper@google.com>2015-03-31 14:34:15 +0000
commitf46dec86b647ea5bebeb08eaf4d51471c930f1ba (patch)
treec7a84166a184e33144e9c86223d5e64b629a9c7a /clang/unittests/Format/FormatTestJS.cpp
parent462501ee7e05d9ccad2515277159f818c181b6ae (diff)
downloadbcm5719-llvm-f46dec86b647ea5bebeb08eaf4d51471c930f1ba.tar.gz
bcm5719-llvm-f46dec86b647ea5bebeb08eaf4d51471c930f1ba.zip
clang-format: [JS] Support getters, setters and methods in object literals.
llvm-svn: 233698
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 4378ded5c36..00744728ddb 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -144,6 +144,27 @@ TEST_F(FormatTestJS, ContainerLiterals) {
verifyFormat("x = foo && {a: 123};");
}
+TEST_F(FormatTestJS, MethodsInObjectLiterals) {
+ verifyFormat("var o = {\n"
+ " value: 'test',\n"
+ " get value() { // getter\n"
+ " return this.value;\n"
+ " }\n"
+ "};");
+ verifyFormat("var o = {\n"
+ " value: 'test',\n"
+ " set value(val) { // setter\n"
+ " this.value = val;\n"
+ " }\n"
+ "};");
+ verifyFormat("var o = {\n"
+ " value: 'test',\n"
+ " someMethod(val) { // method\n"
+ " doSomething(this.value + val);\n"
+ " }\n"
+ "};");
+}
+
TEST_F(FormatTestJS, SpacesInContainerLiterals) {
verifyFormat("var arr = [1, 2, 3];");
verifyFormat("f({a: 1, b: 2, c: 3});");
OpenPOWER on IntegriCloud