From 31d6da7c0ca24fd247078c32c16e0e95b99e20d6 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Thu, 23 Jun 2016 21:51:49 +0000 Subject: clang-format: [JS] handle conditionals in fields, default params. Summary: Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21658 llvm-svn: 273619 --- clang/unittests/Format/FormatTestJS.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'clang/unittests/Format/FormatTestJS.cpp') diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index bd5a505d59e..3b9667d5ca4 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1253,7 +1253,6 @@ TEST_F(FormatTestJS, OptionalTypes) { verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " aaaaaaaa?: string,\n" @@ -1350,5 +1349,14 @@ TEST_F(FormatTestJS, NonNullAssertionOperator) { verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x ? 1 : 2;"); + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang -- cgit v1.2.3