From 559b49baa9380bfd77681aa466444e1d9c37d5cf Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 9 Jun 2016 11:33:53 -0700 Subject: [PATCH] Improve tests --- .../ambientDeclarationsPatterns.errors.txt | 29 ---------- .../reference/ambientDeclarationsPatterns.js | 24 ++++++--- .../ambientDeclarationsPatterns.symbols | 51 ++++++++++++++++++ .../ambientDeclarationsPatterns.types | 54 +++++++++++++++++++ ...ationsPatterns_tooManyAsterisks.errors.txt | 8 +++ ...ntDeclarationsPatterns_tooManyAsterisks.js | 5 ++ .../ambient/ambientDeclarationsPatterns.ts | 19 ++++--- ...ntDeclarationsPatterns_tooManyAsterisks.ts | 1 + 8 files changed, 150 insertions(+), 41 deletions(-) delete mode 100644 tests/baselines/reference/ambientDeclarationsPatterns.errors.txt create mode 100644 tests/baselines/reference/ambientDeclarationsPatterns.symbols create mode 100644 tests/baselines/reference/ambientDeclarationsPatterns.types create mode 100644 tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.errors.txt create mode 100644 tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.js create mode 100644 tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns.errors.txt deleted file mode 100644 index 8fc7e4a3d18..00000000000 --- a/tests/baselines/reference/ambientDeclarationsPatterns.errors.txt +++ /dev/null @@ -1,29 +0,0 @@ -tests/cases/conformance/ambient/declarations.d.ts(10,16): error TS5061: Pattern 'too*many*asterisks' can have at most one '*' character - - -==== tests/cases/conformance/ambient/user.ts (0 errors) ==== - /// - import {foo, baz} from "foobarbaz"; - foo(baz); - - import {foos} from "foosball"; - -==== tests/cases/conformance/ambient/declarations.d.ts (1 errors) ==== - declare module "foo*baz" { - export function foo(n: number): void; - } - // Augmentations still work - declare module "foo*baz" { - export const baz: number; - } - - // Should be an error - declare module "too*many*asterisks" { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS5061: Pattern 'too*many*asterisks' can have at most one '*' character - - // Longest prefix wins - declare module "foos*" { - export const foos: number; - } - \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.js b/tests/baselines/reference/ambientDeclarationsPatterns.js index ee9833a3a37..143f26550e9 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns.js @@ -2,19 +2,21 @@ //// [declarations.d.ts] declare module "foo*baz" { - export function foo(n: number): void; + export function foo(s: string): void; } // Augmentations still work declare module "foo*baz" { - export const baz: number; + export const baz: string; } -// Should be an error -declare module "too*many*asterisks" { } - // Longest prefix wins declare module "foos*" { - export const foos: number; + export const foos: string; +} + +declare module "*!text" { + const x: string; + export default x; } //// [user.ts] @@ -23,6 +25,11 @@ import {foo, baz} from "foobarbaz"; foo(baz); import {foos} from "foosball"; +foo(foos); + +// Works with relative file name +import fileText from "./file!text"; +foo(fileText); //// [user.js] @@ -30,3 +37,8 @@ import {foos} from "foosball"; /// var foobarbaz_1 = require("foobarbaz"); foobarbaz_1.foo(foobarbaz_1.baz); +var foosball_1 = require("foosball"); +foobarbaz_1.foo(foosball_1.foos); +// Works with relative file name +var file_text_1 = require("./file!text"); +foobarbaz_1.foo(file_text_1["default"]); diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.symbols b/tests/baselines/reference/ambientDeclarationsPatterns.symbols new file mode 100644 index 00000000000..4c0acc93f8f --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/ambient/user.ts === +/// +import {foo, baz} from "foobarbaz"; +>foo : Symbol(foo, Decl(user.ts, 1, 8)) +>baz : Symbol(baz, Decl(user.ts, 1, 12)) + +foo(baz); +>foo : Symbol(foo, Decl(user.ts, 1, 8)) +>baz : Symbol(baz, Decl(user.ts, 1, 12)) + +import {foos} from "foosball"; +>foos : Symbol(foos, Decl(user.ts, 4, 8)) + +foo(foos); +>foo : Symbol(foo, Decl(user.ts, 1, 8)) +>foos : Symbol(foos, Decl(user.ts, 4, 8)) + +// Works with relative file name +import fileText from "./file!text"; +>fileText : Symbol(fileText, Decl(user.ts, 8, 6)) + +foo(fileText); +>foo : Symbol(foo, Decl(user.ts, 1, 8)) +>fileText : Symbol(fileText, Decl(user.ts, 8, 6)) + +=== tests/cases/conformance/ambient/declarations.d.ts === +declare module "foo*baz" { + export function foo(s: string): void; +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 26)) +>s : Symbol(s, Decl(declarations.d.ts, 1, 24)) +} +// Augmentations still work +declare module "foo*baz" { + export const baz: string; +>baz : Symbol(baz, Decl(declarations.d.ts, 5, 16)) +} + +// Longest prefix wins +declare module "foos*" { + export const foos: string; +>foos : Symbol(foos, Decl(declarations.d.ts, 10, 16)) +} + +declare module "*!text" { + const x: string; +>x : Symbol(x, Decl(declarations.d.ts, 14, 9)) + + export default x; +>x : Symbol(x, Decl(declarations.d.ts, 14, 9)) +} + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.types b/tests/baselines/reference/ambientDeclarationsPatterns.types new file mode 100644 index 00000000000..adf8ae1ab3b --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/ambient/user.ts === +/// +import {foo, baz} from "foobarbaz"; +>foo : (s: string) => void +>baz : string + +foo(baz); +>foo(baz) : void +>foo : (s: string) => void +>baz : string + +import {foos} from "foosball"; +>foos : string + +foo(foos); +>foo(foos) : void +>foo : (s: string) => void +>foos : string + +// Works with relative file name +import fileText from "./file!text"; +>fileText : string + +foo(fileText); +>foo(fileText) : void +>foo : (s: string) => void +>fileText : string + +=== tests/cases/conformance/ambient/declarations.d.ts === +declare module "foo*baz" { + export function foo(s: string): void; +>foo : (s: string) => void +>s : string +} +// Augmentations still work +declare module "foo*baz" { + export const baz: string; +>baz : string +} + +// Longest prefix wins +declare module "foos*" { + export const foos: string; +>foos : string +} + +declare module "*!text" { + const x: string; +>x : string + + export default x; +>x : string +} + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.errors.txt b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.errors.txt new file mode 100644 index 00000000000..7a3ff02aa5e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts(1,16): error TS5061: Pattern 'too*many*asterisks' can have at most one '*' character + + +==== tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts (1 errors) ==== + declare module "too*many*asterisks" { } + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS5061: Pattern 'too*many*asterisks' can have at most one '*' character + \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.js b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.js new file mode 100644 index 00000000000..a664eb84dc5 --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.js @@ -0,0 +1,5 @@ +//// [ambientDeclarationsPatterns_tooManyAsterisks.ts] +declare module "too*many*asterisks" { } + + +//// [ambientDeclarationsPatterns_tooManyAsterisks.js] diff --git a/tests/cases/conformance/ambient/ambientDeclarationsPatterns.ts b/tests/cases/conformance/ambient/ambientDeclarationsPatterns.ts index 43e373ba9de..d48f50bfa50 100644 --- a/tests/cases/conformance/ambient/ambientDeclarationsPatterns.ts +++ b/tests/cases/conformance/ambient/ambientDeclarationsPatterns.ts @@ -1,18 +1,20 @@ // @Filename: declarations.d.ts declare module "foo*baz" { - export function foo(n: number): void; + export function foo(s: string): void; } // Augmentations still work declare module "foo*baz" { - export const baz: number; + export const baz: string; } -// Should be an error -declare module "too*many*asterisks" { } - // Longest prefix wins declare module "foos*" { - export const foos: number; + export const foos: string; +} + +declare module "*!text" { + const x: string; + export default x; } // @Filename: user.ts @@ -21,3 +23,8 @@ import {foo, baz} from "foobarbaz"; foo(baz); import {foos} from "foosball"; +foo(foos); + +// Works with relative file name +import fileText from "./file!text"; +foo(fileText); diff --git a/tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts new file mode 100644 index 00000000000..76f9081906c --- /dev/null +++ b/tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts @@ -0,0 +1 @@ +declare module "too*many*asterisks" { }