summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index ca2093a05cc..30a0b37ef69 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2222,6 +2222,16 @@ TEST_F(FormatTestJS, NonNullAssertionOperator) {
verifyFormat("return !!x;\n");
}
+TEST_F(FormatTestJS, NullPropagatingOperator) {
+ verifyFormat("let x = foo?.bar?.baz();\n");
+ verifyFormat("let x = foo?.(foo);\n");
+ verifyFormat("let x = foo?.['arr'];\n");
+}
+
+TEST_F(FormatTestJS, NullishCoalescingOperator) {
+ verifyFormat("const val = something ?? 'some other default';\n");
+}
+
TEST_F(FormatTestJS, Conditional) {
verifyFormat("y = x ? 1 : 2;");
verifyFormat("x ? 1 : 2;");
OpenPOWER on IntegriCloud