mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Added test for abstract-classes
This commit is contained in:
36
tests/cases/compiler/abstractClass1.ts
Normal file
36
tests/cases/compiler/abstractClass1.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// @declaration: true
|
||||
|
||||
abstract class Foo {
|
||||
constructor(f: any) { }
|
||||
public static bar(): void { }
|
||||
|
||||
public empty() { }
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
constructor(f: any) {
|
||||
super(f);
|
||||
}
|
||||
}
|
||||
|
||||
var a = new Foo(1); // Error
|
||||
var b = new Foo(); // Error because of invalid constructor arguments
|
||||
|
||||
module baz {
|
||||
export abstract class Qux {
|
||||
}
|
||||
export class Quz extends Qux {
|
||||
}
|
||||
}
|
||||
|
||||
new baz.Qux();
|
||||
|
||||
// Valid
|
||||
var c = new Bar(1);
|
||||
c.empty();
|
||||
|
||||
// Calling a static method on a abstract class is valid
|
||||
Foo.bar();
|
||||
|
||||
var Copy = Foo;
|
||||
new Copy();
|
||||
4
tests/cases/compiler/abstractClassIdentifierName.ts
Normal file
4
tests/cases/compiler/abstractClassIdentifierName.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
class abstract {
|
||||
|
||||
abstract(): void { }
|
||||
}
|
||||
6
tests/cases/compiler/abstractIdentifierNameStrict.ts
Normal file
6
tests/cases/compiler/abstractIdentifierNameStrict.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
var abstract = true;
|
||||
|
||||
function foo() {
|
||||
"use strict";
|
||||
var abstract = true;
|
||||
}
|
||||
4
tests/cases/compiler/abstractInterfaceIdentifierName.ts
Normal file
4
tests/cases/compiler/abstractInterfaceIdentifierName.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
interface abstract {
|
||||
abstract(): void;
|
||||
}
|
||||
Reference in New Issue
Block a user