added tests

This commit is contained in:
Vladimir Matveev
2015-04-11 08:50:11 -07:00
parent e2ba13eb17
commit e622c8ec34
37 changed files with 621 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
@@ -20,7 +20,7 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ====
///<reference path='constDeclarations_access_1.ts'/>
import m = require('constDeclarations_access_1');

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6-amd.ts (0 errors) ====
class A

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ====
class A

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ====
class A

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts (0 errors) ====
export var a = 10;

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6ImportNameSpaceImport_0.ts (0 errors) ====
export var a = 10;

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6ImportNamedImport_0.ts (0 errors) ====
export var a = 10;

View File

@@ -1,8 +1,8 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts (0 errors) ====
export var a = 10;

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ====
export class A
{

View File

@@ -1,7 +1,7 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ====
export class A
{

View File

@@ -0,0 +1,7 @@
error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.
==== tests/cases/compiler/systemModule1.ts (0 errors) ====
export var x = 1;

View File

@@ -0,0 +1,6 @@
//// [systemModule1.ts]
export var x = 1;
//// [systemModule1.js]
export var x = 1;

View File

@@ -0,0 +1,9 @@
tests/cases/compiler/systemModule2.ts(3,1): error TS1212: Export assignment is not supported when '--module' flag is 'system'.
==== tests/cases/compiler/systemModule2.ts (1 errors) ====
var x = 1;
export = x;
~~~~~~~~~~~
!!! error TS1212: Export assignment is not supported when '--module' flag is 'system'.

View File

@@ -0,0 +1,15 @@
//// [systemModule2.ts]
var x = 1;
export = x;
//// [systemModule2.js]
System.register([], function(exports_1) {
var x;
return {
setters:[],
execute: function() {
x = 1;
}
}
});

View File

@@ -0,0 +1,69 @@
//// [tests/cases/compiler/systemModule3.ts] ////
//// [file1.ts]
export default function() {}
//// [file2.ts]
export default function f() {}
//// [file3.ts]
export default class C {}
//// [file4.ts]
export default class {}
//// [file1.js]
System.register([], function(exports_1) {
function default_1() { }
exports_1("default", default_1);
return {
setters:[],
execute: function() {
}
}
});
//// [file2.js]
System.register([], function(exports_1) {
function f() { }
exports_1("default", f);
return {
setters:[],
execute: function() {
}
}
});
//// [file3.js]
System.register([], function(exports_1) {
var C;
return {
setters:[],
execute: function() {
C = (function () {
function C() {
}
return C;
})();
exports_1("default", C);
}
}
});
//// [file4.js]
System.register([], function(exports_1) {
var default_1;
return {
setters:[],
execute: function() {
default_1 = (function () {
function default_1() {
}
return default_1;
})();
exports_1("default", default_1);
}
}
});

View File

@@ -0,0 +1,19 @@
=== tests/cases/compiler/file1.ts ===
No type information for this code.
No type information for this code.export default function() {}
No type information for this code.
No type information for this code.=== tests/cases/compiler/file2.ts ===
export default function f() {}
>f : () => void
=== tests/cases/compiler/file3.ts ===
export default class C {}
>C : C
=== tests/cases/compiler/file4.ts ===
No type information for this code.export default class {}
No type information for this code.

View File

@@ -0,0 +1,16 @@
//// [systemModule4.ts]
export var x = 1;
export var y;
//// [systemModule4.js]
System.register([], function(exports_1) {
var x, y;
return {
setters:[],
execute: function() {
exports_1("x", x = 1);
exports_1("y", y);
}
}
});

View File

@@ -0,0 +1,8 @@
=== tests/cases/compiler/systemModule4.ts ===
export var x = 1;
>x : number
export var y;
>y : any

View File

@@ -0,0 +1,15 @@
//// [systemModule5.ts]
export function foo() {}
//// [systemModule5.js]
System.register([], function(exports_1) {
function foo() { }
exports_1("foo", foo);
return {
setters:[],
execute: function() {
}
}
});

View File

@@ -0,0 +1,5 @@
=== tests/cases/compiler/systemModule5.ts ===
export function foo() {}
>foo : () => void

View File

@@ -0,0 +1,26 @@
//// [systemModule6.ts]
export class C {}
function foo() {
new C();
}
//// [systemModule6.js]
System.register([], function(exports_1) {
var C;
function foo() {
new C();
}
return {
setters:[],
execute: function() {
C = (function () {
function C() {
}
return C;
})();
exports_1("C", C);
}
}
});

View File

@@ -0,0 +1,13 @@
=== tests/cases/compiler/systemModule6.ts ===
export class C {}
>C : C
function foo() {
>foo : () => void
new C();
>new C() : C
>C : typeof C
}

View File

@@ -0,0 +1,26 @@
//// [systemModule7.ts]
// filename: instantiatedModule.ts
export module M {
var x = 1;
}
// filename: nonInstantiatedModule.ts
export module M {
interface I {}
}
//// [systemModule7.js]
System.register([], function(exports_1) {
var M;
return {
setters:[],
execute: function() {
// filename: instantiatedModule.ts
(function (M) {
var x = 1;
})(M = M || (M = {}));
exports_1("M", M)
}
}
});

View File

@@ -0,0 +1,17 @@
=== tests/cases/compiler/systemModule7.ts ===
// filename: instantiatedModule.ts
export module M {
>M : typeof M
var x = 1;
>x : number
}
// filename: nonInstantiatedModule.ts
export module M {
>M : typeof M
interface I {}
>I : I
}

View File

@@ -0,0 +1,59 @@
//// [systemModule8.ts]
export var x;
x = 1;
x++;
x--;
++x;
--x;
x += 1;
x -= 1;
x *= 1;
x /= 1;
x |= 1;
x &= 1;
for (x = 5;;x++) {}
for (x = 8;;x--) {}
for (let x = 50;;) {}
function foo() {
x = 100;
}
export let [y] = [1];
export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}};
for ([x] of [[1]]) {}
//// [systemModule8.js]
System.register([], function(exports_1) {
var x, x_1, y, z0, z1;
function foo() {
exports_1("x", x = 100);
}
return {
setters:[],
execute: function() {
exports_1("x", x);
exports_1("x", x = 1);
exports_1("x", x++), x - 1;
exports_1("x", x--), x + 1;
exports_1("x", ++x);
exports_1("x", --x);
exports_1("x", x += 1);
exports_1("x", x -= 1);
exports_1("x", x *= 1);
exports_1("x", x /= 1);
exports_1("x", x |= 1);
exports_1("x", x &= 1);
for (exports_1("x", x = 5);; exports_1("x", x++), x - 1) { }
for (exports_1("x", x = 8);; exports_1("x", x--), x + 1) { }
for (x_1 = 50;;) { }
exports_1("y", y = ([1])[0]);
_a = { a: true, b: { c: "123" } }, exports_1("z0", z0 = _a.a), exports_1("z1", z1 = _a.b.c);
for (var _i = 0, _b = [[1]]; _i < _b.length; _i++) {
exports_1("x", x = _b[_i][0]);
}
}
var _a;
}
});

View File

@@ -0,0 +1,94 @@
=== tests/cases/compiler/systemModule8.ts ===
export var x;
>x : any
x = 1;
>x = 1 : number
>x : any
x++;
>x++ : number
>x : any
x--;
>x-- : number
>x : any
++x;
>++x : number
>x : any
--x;
>--x : number
>x : any
x += 1;
>x += 1 : any
>x : any
x -= 1;
>x -= 1 : number
>x : any
x *= 1;
>x *= 1 : number
>x : any
x /= 1;
>x /= 1 : number
>x : any
x |= 1;
>x |= 1 : number
>x : any
x &= 1;
>x &= 1 : number
>x : any
for (x = 5;;x++) {}
>x = 5 : number
>x : any
>x++ : number
>x : any
for (x = 8;;x--) {}
>x = 8 : number
>x : any
>x-- : number
>x : any
for (let x = 50;;) {}
>x : number
function foo() {
>foo : () => void
x = 100;
>x = 100 : number
>x : any
}
export let [y] = [1];
>y : number
>[1] : [number]
export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}};
>a : unknown
>z0 : boolean
>b : unknown
>c : unknown
>z1 : string
>{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; }
>a : boolean
>b : { c: string; }
>{c: "123"} : { c: string; }
>c : string
for ([x] of [[1]]) {}
>[x] : any[]
>x : any
>[[1]] : number[][]
>[1] : number[]

View File

@@ -0,0 +1,41 @@
tests/cases/compiler/systemModule9.ts(2,21): error TS2307: Cannot find external module 'file1'.
tests/cases/compiler/systemModule9.ts(3,25): error TS2307: Cannot find external module 'file2'.
tests/cases/compiler/systemModule9.ts(4,15): error TS2307: Cannot find external module 'file3'.
tests/cases/compiler/systemModule9.ts(5,25): error TS2307: Cannot find external module 'file4'.
tests/cases/compiler/systemModule9.ts(6,22): error TS2307: Cannot find external module 'file5'.
tests/cases/compiler/systemModule9.ts(16,15): error TS2307: Cannot find external module 'file6'.
==== tests/cases/compiler/systemModule9.ts (6 errors) ====
import * as ns from 'file1';
~~~~~~~
!!! error TS2307: Cannot find external module 'file1'.
import {a, b as c} from 'file2';
~~~~~~~
!!! error TS2307: Cannot find external module 'file2'.
import d from 'file3'
~~~~~~~
!!! error TS2307: Cannot find external module 'file3'.
import e, * as ns2 from 'file4';
~~~~~~~
!!! error TS2307: Cannot find external module 'file4'.
import ns3 = require('file5');
~~~~~~~
!!! error TS2307: Cannot find external module 'file5'.
ns.f();
a();
c();
d();
e();
ns2.f();
ns3.f();
export * from 'file6';
~~~~~~~
!!! error TS2307: Cannot find external module 'file6'.
var x, y = true;
export {x};
export {y as z};

View File

@@ -0,0 +1,60 @@
//// [systemModule9.ts]
import * as ns from 'file1';
import {a, b as c} from 'file2';
import d from 'file3'
import e, * as ns2 from 'file4';
import ns3 = require('file5');
ns.f();
a();
c();
d();
e();
ns2.f();
ns3.f();
export * from 'file6';
var x, y = true;
export {x};
export {y as z};
//// [systemModule9.js]
System.register(['file1', 'file2', 'file3', 'file4', 'file5', 'file6'], function(exports_1) {
var ns, file2_1, file3_1, file4_1, ns3;
var x, y;
return {
setters:[
function (v_1) {
ns = v_1
},
function (v_1) {
file2_1 = v_1
},
function (v_1) {
file3_1 = v_1
},
function (v_1) {
file4_1 = v_1
},
function (v_1) {
ns3 = v_1
},
function (v_1) {
for (var n in v_1) exports_1(n, v_1[n]);
}],
execute: function() {
ns.f();
file2_1.a();
file2_1.b();
file3_1.default();
file4_1.default();
ns2.f();
ns3.f();
y = true;
exports_1("x", x);
exports_1("z", y);
}
}
});

View File

@@ -0,0 +1,4 @@
// @target: es6
// @module: system
export var x = 1;

View File

@@ -0,0 +1,4 @@
// @module: system
var x = 1;
export = x;

View File

@@ -0,0 +1,17 @@
// @module: system
// @filename: file1.ts
export default function() {}
// @filename: file2.ts
export default function f() {}
// @filename: file3.ts
export default class C {}
// @filename: file4.ts
export default class {}

View File

@@ -0,0 +1,4 @@
// @module: system
export var x = 1;
export var y;

View File

@@ -0,0 +1,3 @@
// @module: system
export function foo() {}

View File

@@ -0,0 +1,6 @@
// @module: system
export class C {}
function foo() {
new C();
}

View File

@@ -0,0 +1,11 @@
// @module: system
// filename: instantiatedModule.ts
export module M {
var x = 1;
}
// filename: nonInstantiatedModule.ts
export module M {
interface I {}
}

View File

@@ -0,0 +1,25 @@
// @module: system
export var x;
x = 1;
x++;
x--;
++x;
--x;
x += 1;
x -= 1;
x *= 1;
x /= 1;
x |= 1;
x &= 1;
for (x = 5;;x++) {}
for (x = 8;;x--) {}
for (let x = 50;;) {}
function foo() {
x = 100;
}
export let [y] = [1];
export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}};
for ([x] of [[1]]) {}

View File

@@ -0,0 +1,22 @@
// @module: system
// @separateCompilation: true
import * as ns from 'file1';
import {a, b as c} from 'file2';
import d from 'file3'
import e, * as ns2 from 'file4';
import ns3 = require('file5');
ns.f();
a();
c();
d();
e();
ns2.f();
ns3.f();
export * from 'file6';
var x, y = true;
export {x};
export {y as z};