]> granicus.if.org Git - clang/commitdiff
Summary:
authorMartin Probst <martin@probst.io>
Tue, 19 Apr 2016 14:59:16 +0000 (14:59 +0000)
committerMartin Probst <martin@probst.io>
Tue, 19 Apr 2016 14:59:16 +0000 (14:59 +0000)
clang-format: [JS] unit tests for type aliases.

Also adds a test for "foo as bar" casts.

Spec:
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.10

These are already handled correctly.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D19206

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266744 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Format/FormatTestJS.cpp

index a3cb6016d6402a10cb44b476fb8ee7a102073768..aa79fa30245994417c67bfddbde039117df89679 100644 (file)
@@ -943,6 +943,16 @@ TEST_F(FormatTestJS, MetadataAnnotations) {
                "class Y {}");
 }
 
+TEST_F(FormatTestJS, TypeAliases) {
+  verifyFormat("type X = number;\n"
+               "class C {}");
+  verifyFormat("type X<Y> = Z<Y>;");
+  verifyFormat("type X = {\n"
+               "  y: number\n"
+               "};\n"
+               "class C {}");
+}
+
 TEST_F(FormatTestJS, Modules) {
   verifyFormat("import SomeThing from 'some/module.js';");
   verifyFormat("import {X, Y} from 'some/module.js';");
@@ -1095,7 +1105,10 @@ TEST_F(FormatTestJS, TemplateStrings) {
                "var y;");
 }
 
-TEST_F(FormatTestJS, CastSyntax) { verifyFormat("var x = <type>foo;"); }
+TEST_F(FormatTestJS, CastSyntax) {
+  verifyFormat("var x = <type>foo;");
+  verifyFormat("var x = foo as type;");
+}
 
 TEST_F(FormatTestJS, TypeArguments) {
   verifyFormat("class X<Y> {}");