From ec7e80e377fae0360bccb30f937adc2693c592ca Mon Sep 17 00:00:00 2001 From: AbubakerB Date: Sat, 13 Feb 2016 01:10:47 +0000 Subject: [PATCH] Added tests and accept baselines --- .../classConstructorAccessibility4.errors.txt | 42 +++++++++++++++++++ .../classConstructorAccessibility4.ts | 33 +++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 tests/baselines/reference/classConstructorAccessibility4.errors.txt create mode 100644 tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts diff --git a/tests/baselines/reference/classConstructorAccessibility4.errors.txt b/tests/baselines/reference/classConstructorAccessibility4.errors.txt new file mode 100644 index 0000000000..1cc50e3f4c --- /dev/null +++ b/tests/baselines/reference/classConstructorAccessibility4.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts(16,9): error TS2673: Constructor of class 'A' is private and only accessible within the class declaration. +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts(33,9): error TS2674: Constructor of class 'D' is protected and only accessible within the class declaration. + + +==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts (2 errors) ==== + class A { + private constructor() { } + + method() { + class B { + method() { + new A(); // OK + } + } + + class C extends A { // OK + } + } + } + + var a = new A(); // error + ~~~~~~~ +!!! error TS2673: Constructor of class 'A' is private and only accessible within the class declaration. + + class D { + protected constructor() { } + + method() { + class E { + method() { + new D(); // OK + } + } + + class F extends D { // OK + } + } + } + + var d = new D(); // error + ~~~~~~~ +!!! error TS2674: Constructor of class 'D' is protected and only accessible within the class declaration. \ No newline at end of file diff --git a/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts b/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts new file mode 100644 index 0000000000..e75f9be6fd --- /dev/null +++ b/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility4.ts @@ -0,0 +1,33 @@ +class A { + private constructor() { } + + method() { + class B { + method() { + new A(); // OK + } + } + + class C extends A { // OK + } + } +} + +var a = new A(); // error + +class D { + protected constructor() { } + + method() { + class E { + method() { + new D(); // OK + } + } + + class F extends D { // OK + } + } +} + +var d = new D(); // error \ No newline at end of file