Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Add type parameter scope tests (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
zertosh committed Mar 23, 2017
1 parent 3cda62e commit 21dac73
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ describe("verify", () => {
);
});

it("type parameter scope (classes)", () => {
verifyAndAssertMessages(
unpad(`
T;
class Foo<T> {}
T;
new Foo();
`),
{ "no-unused-vars": 1, "no-undef": 1 },
[ "1:1 'T' is not defined. no-undef",
"2:11 'T' is defined but never used. no-unused-vars",
"3:1 'T' is not defined. no-undef" ]
);
});

it("type parameter bounds (interfaces)", () => {
verifyAndAssertMessages(
unpad(`
Expand All @@ -264,6 +279,21 @@ describe("verify", () => {
);
});

it("type parameter scope (interfaces)", () => {
verifyAndAssertMessages(
unpad(`
T;
interface Foo<T> {};
T;
Foo;
`),
{ "no-unused-vars": 1, "no-undef": 1 },
[ "1:1 'T' is not defined. no-undef",
"2:15 'T' is defined but never used. no-unused-vars",
"3:1 'T' is not defined. no-undef" ]
);
});

it("type parameter bounds (type aliases)", () => {
verifyAndAssertMessages(
unpad(`
Expand All @@ -279,6 +309,21 @@ describe("verify", () => {
);
});

it("type parameter scope (type aliases)", () => {
verifyAndAssertMessages(
unpad(`
T;
type Foo<T> = {};
T;
Foo;
`),
{ "no-unused-vars": 1, "no-undef": 1 },
[ "1:1 'T' is not defined. no-undef",
"2:10 'T' is defined but never used. no-unused-vars",
"3:1 'T' is not defined. no-undef" ]
);
});

it("type parameter bounds (functions)", () => {
verifyAndAssertMessages(
unpad(`
Expand All @@ -292,6 +337,21 @@ describe("verify", () => {
);
});

it("type parameter scope (functions)", () => {
verifyAndAssertMessages(
unpad(`
T;
function log<T>() {}
T;
log;
`),
{ "no-unused-vars": 1, "no-undef": 1 },
[ "1:1 'T' is not defined. no-undef",
"2:14 'T' is defined but never used. no-unused-vars",
"3:1 'T' is not defined. no-undef" ]
);
});

it("nested type annotations", () => {
verifyAndAssertMessages(
unpad(`
Expand Down

0 comments on commit 21dac73

Please sign in to comment.