From 764af0e78106eb21f4f05d2f0eac73954de364c1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Sep 2017 11:05:40 -0700 Subject: [PATCH] Added tests and accepted baselines. --- src/harness/unittests/printer.ts | 23 +++++++++++++++++++ ...tsNodeCorrectly.emptyGlobalAugmentation.js | 1 + ...yGlobalAugmentationWithNoDeclareKeyword.js | 1 + 3 files changed, 25 insertions(+) create mode 100644 tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js create mode 100644 tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 825bfddbb4a..2bbc19881a3 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -110,6 +110,29 @@ namespace ts { createSourceFile("source.ts", "", ScriptTarget.ES2015) )); + + printsCorrectly("emptyGlobalAugmentation", {}, printer => printer.printNode( + EmitHint.Unspecified, + createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ [createToken(SyntaxKind.DeclareKeyword)], + createIdentifier("global"), + createModuleBlock(emptyArray), + NodeFlags.GlobalAugmentation), + createSourceFile("source.ts", "", ScriptTarget.ES2015) + )); + + printsCorrectly("emptyGlobalAugmentationWithNoDeclareKeyword", {}, printer => printer.printNode( + EmitHint.Unspecified, + createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createIdentifier("global"), + createModuleBlock(emptyArray), + NodeFlags.GlobalAugmentation), + createSourceFile("source.ts", "", ScriptTarget.ES2015) + )); + // https://github.com/Microsoft/TypeScript/issues/15971 printsCorrectly("classWithOptionalMethodAndProperty", {}, printer => printer.printNode( EmitHint.Unspecified, diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js new file mode 100644 index 00000000000..2a8c3b88e16 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js @@ -0,0 +1 @@ +declare module global { } \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js new file mode 100644 index 00000000000..4cc10f41f8f --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js @@ -0,0 +1 @@ +module global { } \ No newline at end of file