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

Add type parameter scope tests #454

Merged
merged 1 commit into from
Mar 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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