From bb638db18d8f63d0370de9eeccabe13f152ac625 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 15 Aug 2014 13:57:55 -0700 Subject: [PATCH] Test cases for trailing comments for import declaration --- .../reference/commentsExternalModules.js | 2 +- .../reference/commentsExternalModules2.js | 2 +- .../reference/commentsExternalModules3.js | 174 ++++++++++++++++++ .../cases/compiler/commentsExternalModules.ts | 2 +- .../compiler/commentsExternalModules2.ts | 2 +- .../compiler/commentsExternalModules3.ts | 63 +++++++ 6 files changed, 241 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/commentsExternalModules3.js create mode 100644 tests/cases/compiler/commentsExternalModules3.ts diff --git a/tests/baselines/reference/commentsExternalModules.js b/tests/baselines/reference/commentsExternalModules.js index 33db2669c6f..9768d9617bd 100644 --- a/tests/baselines/reference/commentsExternalModules.js +++ b/tests/baselines/reference/commentsExternalModules.js @@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.ts] /**This is on import declaration*/ -import extMod = require("commentsExternalModules_0"); +import extMod = require("commentsExternalModules_0"); // trailing comment1 extMod.m1.fooExport(); var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/baselines/reference/commentsExternalModules2.js b/tests/baselines/reference/commentsExternalModules2.js index 41bf2420e3d..b8fe07630ec 100644 --- a/tests/baselines/reference/commentsExternalModules2.js +++ b/tests/baselines/reference/commentsExternalModules2.js @@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.ts] /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); +import extMod = require("commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); export var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/baselines/reference/commentsExternalModules3.js b/tests/baselines/reference/commentsExternalModules3.js new file mode 100644 index 00000000000..4b241aca02e --- /dev/null +++ b/tests/baselines/reference/commentsExternalModules3.js @@ -0,0 +1,174 @@ +//// [tests/cases/compiler/commentsExternalModules3.ts] //// + +//// [commentsExternalModules2_0.ts] + +/** Module comment*/ +export module m1 { + /** b's comment*/ + export var b: number; + /** foo's comment*/ + function foo() { + return b; + } + /** m2 comments*/ + export module m2 { + /** class comment;*/ + export class c { + }; + /** i*/ + export var i = new c(); + } + /** exported function*/ + export function fooExport() { + return foo(); + } +} +m1.fooExport(); +var myvar = new m1.m2.c(); + +/** Module comment */ +export module m4 { + /** b's comment */ + export var b: number; + /** foo's comment + */ + function foo() { + return b; + } + /** m2 comments + */ + export module m2 { + /** class comment; */ + export class c { + }; + /** i */ + export var i = new c(); + } + /** exported function */ + export function fooExport() { + return foo(); + } +} +m4.fooExport(); +var myvar2 = new m4.m2.c(); + +//// [commentsExternalModules_1.ts] +/**This is on import declaration*/ +import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +extMod.m1.fooExport(); +export var newVar = new extMod.m1.m2.c(); +extMod.m4.fooExport(); +export var newVar2 = new extMod.m4.m2.c(); + + +//// [commentsExternalModules2_0.js] +/** Module comment*/ +(function (m1) { + /** b's comment*/ + m1.b; + /** foo's comment*/ + function foo() { + return m1.b; + } + /** m2 comments*/ + (function (m2) { + /** class comment;*/ + var c = (function () { + function c() { + } + return c; + })(); + m2.c = c; + ; + /** i*/ + m2.i = new c(); + })(m1.m2 || (m1.m2 = {})); + var m2 = m1.m2; + /** exported function*/ + function fooExport() { + return foo(); + } + m1.fooExport = fooExport; +})(exports.m1 || (exports.m1 = {})); +var m1 = exports.m1; +m1.fooExport(); +var myvar = new m1.m2.c(); +/** Module comment */ +(function (m4) { + /** b's comment */ + m4.b; + /** foo's comment + */ + function foo() { + return m4.b; + } + /** m2 comments + */ + (function (m2) { + /** class comment; */ + var c = (function () { + function c() { + } + return c; + })(); + m2.c = c; + ; + /** i */ + m2.i = new c(); + })(m4.m2 || (m4.m2 = {})); + var m2 = m4.m2; + /** exported function */ + function fooExport() { + return foo(); + } + m4.fooExport = fooExport; +})(exports.m4 || (exports.m4 = {})); +var m4 = exports.m4; +m4.fooExport(); +var myvar2 = new m4.m2.c(); +//// [commentsExternalModules_1.js] +/**This is on import declaration*/ +var extMod = require("commentsExternalModules2_0"); // trailing comment 1 +extMod.m1.fooExport(); +exports.newVar = new extMod.m1.m2.c(); +extMod.m4.fooExport(); +exports.newVar2 = new extMod.m4.m2.c(); + + +//// [commentsExternalModules2_0.d.ts] +/** Module comment*/ +export declare module m1 { + /** b's comment*/ + var b: number; + /** m2 comments*/ + module m2 { + /** class comment;*/ + class c { + } + /** i*/ + var i: c; + } + /** exported function*/ + function fooExport(): number; +} +/** Module comment */ +export declare module m4 { + /** b's comment */ + var b: number; + /** m2 comments + */ + module m2 { + /** class comment; */ + class c { + } + /** i */ + var i: c; + } + /** exported function */ + function fooExport(): number; +} +//// [commentsExternalModules_1.d.ts] +/**This is on import declaration*/ +import extMod = require("commentsExternalModules2_0"); +export declare var newVar: extMod.m1.m2.c; +export declare var newVar2: extMod.m4.m2.c; diff --git a/tests/cases/compiler/commentsExternalModules.ts b/tests/cases/compiler/commentsExternalModules.ts index eff0d1d6740..86c6b2be8d3 100644 --- a/tests/cases/compiler/commentsExternalModules.ts +++ b/tests/cases/compiler/commentsExternalModules.ts @@ -56,7 +56,7 @@ var myvar2 = new m4.m2.c(); // @Filename: commentsExternalModules_1.ts /**This is on import declaration*/ -import extMod = require("commentsExternalModules_0"); +import extMod = require("commentsExternalModules_0"); // trailing comment1 extMod.m1.fooExport(); var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/cases/compiler/commentsExternalModules2.ts b/tests/cases/compiler/commentsExternalModules2.ts index 76f00e4fe96..354e74738be 100644 --- a/tests/cases/compiler/commentsExternalModules2.ts +++ b/tests/cases/compiler/commentsExternalModules2.ts @@ -56,7 +56,7 @@ var myvar2 = new m4.m2.c(); // @Filename: commentsExternalModules_1.ts /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); +import extMod = require("commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); export var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/cases/compiler/commentsExternalModules3.ts b/tests/cases/compiler/commentsExternalModules3.ts new file mode 100644 index 00000000000..2f214c5d28c --- /dev/null +++ b/tests/cases/compiler/commentsExternalModules3.ts @@ -0,0 +1,63 @@ +//@module: commonjs +// @target: ES5 +// @declaration: true +// @comments: true + +// @Filename: commentsExternalModules2_0.ts +/** Module comment*/ +export module m1 { + /** b's comment*/ + export var b: number; + /** foo's comment*/ + function foo() { + return b; + } + /** m2 comments*/ + export module m2 { + /** class comment;*/ + export class c { + }; + /** i*/ + export var i = new c(); + } + /** exported function*/ + export function fooExport() { + return foo(); + } +} +m1.fooExport(); +var myvar = new m1.m2.c(); + +/** Module comment */ +export module m4 { + /** b's comment */ + export var b: number; + /** foo's comment + */ + function foo() { + return b; + } + /** m2 comments + */ + export module m2 { + /** class comment; */ + export class c { + }; + /** i */ + export var i = new c(); + } + /** exported function */ + export function fooExport() { + return foo(); + } +} +m4.fooExport(); +var myvar2 = new m4.m2.c(); + +// @Filename: commentsExternalModules_1.ts +/**This is on import declaration*/ +import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +extMod.m1.fooExport(); +export var newVar = new extMod.m1.m2.c(); +extMod.m4.fooExport(); +export var newVar2 = new extMod.m4.m2.c();