Skip to content

Commit 5864a66

Browse files
author
Arthur Ozga
committed
updated baselines on classAbstract tests
1 parent 18d6e73 commit 5864a66

10 files changed

+115
-121
lines changed

tests/baselines/reference/APISample_linter.js

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
//// [APISample_linter.ts]
2-
3-
/*
4-
* Note: This test is a public API sample. The sample sources can be found
5-
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
6-
* Please log a "breaking change" issue for any API breaking change affecting this issue
7-
*/
8-
9-
declare var process: any;
10-
declare var console: any;
11-
declare var readFileSync: any;
12-
13-
import * as ts from "typescript";
14-
15-
export function delint(sourceFile: ts.SourceFile) {
16-
delintNode(sourceFile);
17-
18-
function delintNode(node: ts.Node) {
19-
switch (node.kind) {
20-
case ts.SyntaxKind.ForStatement:
21-
case ts.SyntaxKind.ForInStatement:
22-
case ts.SyntaxKind.WhileStatement:
23-
case ts.SyntaxKind.DoStatement:
24-
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
25-
report(node, "A looping statement's contents should be wrapped in a block body.");
26-
}
27-
break;
28-
29-
case ts.SyntaxKind.IfStatement:
30-
let ifStatement = (<ts.IfStatement>node);
31-
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
32-
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
33-
}
34-
if (ifStatement.elseStatement &&
35-
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
36-
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
37-
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
38-
}
39-
break;
40-
41-
case ts.SyntaxKind.BinaryExpression:
42-
let op = (<ts.BinaryExpression>node).operatorToken.kind;
43-
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
44-
report(node, "Use '===' and '!=='.")
45-
}
46-
break;
47-
}
48-
49-
ts.forEachChild(node, delintNode);
50-
}
51-
52-
function report(node: ts.Node, message: string) {
53-
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
54-
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
55-
}
56-
}
57-
58-
const fileNames = process.argv.slice(2);
59-
fileNames.forEach(fileName => {
60-
// Parse a file
61-
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
62-
63-
// delint it
64-
delint(sourceFile);
2+
3+
/*
4+
* Note: This test is a public API sample. The sample sources can be found
5+
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
6+
* Please log a "breaking change" issue for any API breaking change affecting this issue
7+
*/
8+
9+
declare var process: any;
10+
declare var console: any;
11+
declare var readFileSync: any;
12+
13+
import * as ts from "typescript";
14+
15+
export function delint(sourceFile: ts.SourceFile) {
16+
delintNode(sourceFile);
17+
18+
function delintNode(node: ts.Node) {
19+
switch (node.kind) {
20+
case ts.SyntaxKind.ForStatement:
21+
case ts.SyntaxKind.ForInStatement:
22+
case ts.SyntaxKind.WhileStatement:
23+
case ts.SyntaxKind.DoStatement:
24+
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
25+
report(node, "A looping statement's contents should be wrapped in a block body.");
26+
}
27+
break;
28+
29+
case ts.SyntaxKind.IfStatement:
30+
let ifStatement = (<ts.IfStatement>node);
31+
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
32+
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
33+
}
34+
if (ifStatement.elseStatement &&
35+
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
36+
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
37+
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
38+
}
39+
break;
40+
41+
case ts.SyntaxKind.BinaryExpression:
42+
let op = (<ts.BinaryExpression>node).operatorToken.kind;
43+
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
44+
report(node, "Use '===' and '!=='.")
45+
}
46+
break;
47+
}
48+
49+
ts.forEachChild(node, delintNode);
50+
}
51+
52+
function report(node: ts.Node, message: string) {
53+
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
54+
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
55+
}
56+
}
57+
58+
const fileNames = process.argv.slice(2);
59+
fileNames.forEach(fileName => {
60+
// Parse a file
61+
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
62+
63+
// delint it
64+
delint(sourceFile);
6565
});
6666

6767
//// [APISample_linter.js]
@@ -75,26 +75,26 @@ function delint(sourceFile) {
7575
delintNode(sourceFile);
7676
function delintNode(node) {
7777
switch (node.kind) {
78-
case 191 /* ForStatement */:
79-
case 192 /* ForInStatement */:
80-
case 190 /* WhileStatement */:
81-
case 189 /* DoStatement */:
82-
if (node.statement.kind !== 184 /* Block */) {
78+
case 192 /* ForStatement */:
79+
case 193 /* ForInStatement */:
80+
case 191 /* WhileStatement */:
81+
case 190 /* DoStatement */:
82+
if (node.statement.kind !== 185 /* Block */) {
8383
report(node, "A looping statement's contents should be wrapped in a block body.");
8484
}
8585
break;
86-
case 188 /* IfStatement */:
86+
case 189 /* IfStatement */:
8787
var ifStatement = node;
88-
if (ifStatement.thenStatement.kind !== 184 /* Block */) {
88+
if (ifStatement.thenStatement.kind !== 185 /* Block */) {
8989
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
9090
}
9191
if (ifStatement.elseStatement &&
92-
ifStatement.elseStatement.kind !== 184 /* Block */ &&
93-
ifStatement.elseStatement.kind !== 188 /* IfStatement */) {
92+
ifStatement.elseStatement.kind !== 185 /* Block */ &&
93+
ifStatement.elseStatement.kind !== 189 /* IfStatement */) {
9494
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
9595
}
9696
break;
97-
case 173 /* BinaryExpression */:
97+
case 174 /* BinaryExpression */:
9898
var op = node.operatorToken.kind;
9999
if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) {
100100
report(node, "Use '===' and '!=='.");
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration.
1+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
22

33

44
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ====
55
abstract class A {
66
abstract constructor() {}
77
~~~~~~~~
8-
!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration.
8+
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
99
}

tests/baselines/reference/classAbstractDeclarations.d.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1236: 'abstract' modifier can only appear on a class or method declaration.
1+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration.
22
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts.
33
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'.
44
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'.
@@ -9,7 +9,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
99
declare abstract class A {
1010
abstract constructor() {}
1111
~~~~~~~~
12-
!!! error TS1236: 'abstract' modifier can only appear on a class or method declaration.
12+
!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration.
1313
~
1414
!!! error TS1184: An implementation cannot be declared in ambient contexts.
1515
}

tests/baselines/reference/classAbstractInstantiations2.errors.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
33
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'.
44
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'.
55
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration.
6-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be `abstract` or not `abstract.
7-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(49,7): error TS2514: Classes containing abstract methods must be marked abstract.
8-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1238: Abstract methods can only appear within an abstract class.
6+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or not abstract.
7+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class.
98

109

11-
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ====
10+
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ====
1211
class A {
1312
// ...
1413
}
@@ -66,13 +65,11 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
6665
~~~
6766
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
6867
~~~
69-
!!! error TS2512: Overload signatures must all be `abstract` or not `abstract.
68+
!!! error TS2512: Overload signatures must all be abstract or not abstract.
7069
}
7170

7271
class H { // error -- not declared abstract
73-
~
74-
!!! error TS2514: Classes containing abstract methods must be marked abstract.
7572
abstract baz() : number;
7673
~~~~~~~~
77-
!!! error TS1238: Abstract methods can only appear within an abstract class.
74+
!!! error TS1244: Abstract methods can only appear within an abstract class.
7875
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1240: Method 'foo' cannot have an implementation because it is marked abstract.
1+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
22

33

44
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ====
55
abstract class A {
66
abstract foo() {}
77
~~~~~~~~~~~~~~~~~
8-
!!! error TS1240: Method 'foo' cannot have an implementation because it is marked abstract.
8+
!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
99
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1237: 'private' modifier cannot be used with 'abstract' modifier.
1+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
22
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier.
33
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier.
4-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1237: 'private' modifier cannot be used with 'abstract' modifier.
5-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1237: 'static' modifier cannot be used with 'abstract' modifier.
6-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1237: 'static' modifier cannot be used with 'abstract' modifier.
4+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
5+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1243: 'static' modifier cannot be used with 'abstract' modifier.
6+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1243: 'static' modifier cannot be used with 'abstract' modifier.
77

88

99
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts (6 errors) ====
@@ -14,7 +14,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
1414
protected abstract foo_c();
1515
private abstract foo_d();
1616
~~~~~~~~
17-
!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier.
17+
!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
1818

1919
abstract public foo_bb();
2020
~~~~~~
@@ -24,13 +24,13 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
2424
!!! error TS1029: 'protected' modifier must precede 'abstract' modifier.
2525
abstract private foo_dd();
2626
~~~~~~~
27-
!!! error TS1237: 'private' modifier cannot be used with 'abstract' modifier.
27+
!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier.
2828

2929
abstract static foo_d();
3030
~~~~~~
31-
!!! error TS1237: 'static' modifier cannot be used with 'abstract' modifier.
31+
!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier.
3232

3333
static abstract foo_e();
3434
~~~~~~~~
35-
!!! error TS1237: 'static' modifier cannot be used with 'abstract' modifier.
35+
!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier.
3636
}

tests/baselines/reference/classAbstractOverloads.errors.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be `abstract` or not `abstract.
2-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be `abstract` or not `abstract.
3-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be `abstract` or not `abstract.
1+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or not abstract.
2+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or not abstract.
3+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or not abstract.
44
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration.
55
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive.
66

@@ -14,16 +14,16 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
1414
abstract bar();
1515
bar();
1616
~~~
17-
!!! error TS2512: Overload signatures must all be `abstract` or not `abstract.
17+
!!! error TS2512: Overload signatures must all be abstract or not abstract.
1818
abstract bar();
1919

2020
abstract baz();
2121
~~~
22-
!!! error TS2512: Overload signatures must all be `abstract` or not `abstract.
22+
!!! error TS2512: Overload signatures must all be abstract or not abstract.
2323
baz();
2424
abstract baz();
2525
~~~
26-
!!! error TS2512: Overload signatures must all be `abstract` or not `abstract.
26+
!!! error TS2512: Overload signatures must all be abstract or not abstract.
2727
baz() {}
2828

2929
qux();

0 commit comments

Comments
 (0)