Improve tests

This commit is contained in:
Andy Hanson
2016-06-09 11:33:53 -07:00
parent 03371c0e6f
commit 559b49baa9
8 changed files with 150 additions and 41 deletions

View File

@@ -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) ====
///<reference path="declarations.d.ts" />
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;
}

View File

@@ -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";
///<reference path="declarations.d.ts" />
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"]);

View File

@@ -0,0 +1,51 @@
=== tests/cases/conformance/ambient/user.ts ===
///<reference path="declarations.d.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))
}

View File

@@ -0,0 +1,54 @@
=== tests/cases/conformance/ambient/user.ts ===
///<reference path="declarations.d.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
}

View File

@@ -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

View File

@@ -0,0 +1,5 @@
//// [ambientDeclarationsPatterns_tooManyAsterisks.ts]
declare module "too*many*asterisks" { }
//// [ambientDeclarationsPatterns_tooManyAsterisks.js]

View File

@@ -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);

View File

@@ -0,0 +1 @@
declare module "too*many*asterisks" { }