From 13aba26ced01b09a30cff6f012e70230c150684a Mon Sep 17 00:00:00 2001 From: Yui T Date: Thu, 16 Jul 2015 13:41:39 -0700 Subject: [PATCH] Add tests and baseline --- .../reference/classExtendsNull.errors.txt | 21 +++++++++++ tests/baselines/reference/classExtendsNull.js | 35 +++++++++++++++++++ tests/cases/compiler/classExtendsNull.ts | 12 +++++++ 3 files changed, 68 insertions(+) create mode 100644 tests/baselines/reference/classExtendsNull.errors.txt create mode 100644 tests/baselines/reference/classExtendsNull.js create mode 100644 tests/cases/compiler/classExtendsNull.ts diff --git a/tests/baselines/reference/classExtendsNull.errors.txt b/tests/baselines/reference/classExtendsNull.errors.txt new file mode 100644 index 00000000000..93ef3b7765e --- /dev/null +++ b/tests/baselines/reference/classExtendsNull.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/classExtendsNull.ts(2,5): error TS17005: A constructor can not contain super call when a class extends null + + +==== tests/cases/compiler/classExtendsNull.ts (1 errors) ==== + class C extends null { + constructor() { + ~~~~~~~~~~~~~~~ + super(); + ~~~~~~~~~~~~~~~~ + return Object.create(null); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + } + ~~~~~ +!!! error TS17005: A constructor can not contain super call when a class extends null + } + + class D extends null { + constructor() { + return Object.create(null); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsNull.js b/tests/baselines/reference/classExtendsNull.js new file mode 100644 index 00000000000..5627f10dca6 --- /dev/null +++ b/tests/baselines/reference/classExtendsNull.js @@ -0,0 +1,35 @@ +//// [classExtendsNull.ts] +class C extends null { + constructor() { + super(); + return Object.create(null); + } +} + +class D extends null { + constructor() { + return Object.create(null); + } +} + +//// [classExtendsNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.call(this); + return Object.create(null); + } + return C; +})(null); +var D = (function (_super) { + __extends(D, _super); + function D() { + return Object.create(null); + } + return D; +})(null); diff --git a/tests/cases/compiler/classExtendsNull.ts b/tests/cases/compiler/classExtendsNull.ts new file mode 100644 index 00000000000..5532fa72702 --- /dev/null +++ b/tests/cases/compiler/classExtendsNull.ts @@ -0,0 +1,12 @@ +class C extends null { + constructor() { + super(); + return Object.create(null); + } +} + +class D extends null { + constructor() { + return Object.create(null); + } +} \ No newline at end of file