Add conformance tests

This commit is contained in:
Yui T 2014-11-11 11:31:45 -08:00
parent 680999fe3f
commit bb7a0aa9d9
26 changed files with 629 additions and 0 deletions

View file

@ -0,0 +1,39 @@
//// [objectLiteralShorthandProperties.ts]
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
}
var x3 = {
a: 0,
b,
c,
d() { },
x3,
parent: x3
};
//// [objectLiteralShorthandProperties.js]
var a, b, c;
var x1 = {
a: a
};
var x2 = {
a: a
};
var x3 = {
a: 0,
b: b,
c: c,
d: function () {
},
x3: x3,
parent: x3
};

View file

@ -0,0 +1,50 @@
=== tests/cases/compiler/objectLiteralShorthandProperties.ts ===
var a, b, c;
>a : any
>b : any
>c : any
var x1 = {
>x1 : { a: any; }
>{ a} : { a: any; }
a
>a : any
};
var x2 = {
>x2 : { a: any; }
>{ a,} : { a: any; }
a,
>a : any
}
var x3 = {
>x3 : any
>{ a: 0, b, c, d() { }, x3, parent: x3} : { a: number; b: any; c: any; d: () => void; x3: any; parent: any; }
a: 0,
>a : number
b,
>b : any
c,
>c : any
d() { },
>d : () => void
>d() { } : () => void
x3,
>x3 : any
parent: x3
>parent : any
>x3 : any
};

View file

@ -0,0 +1,72 @@
tests/cases/compiler/objectLiteralShorthandProperties2.ts(3,20): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(4,7): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(5,10): error TS1005: '(' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(6,10): error TS1005: '(' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(7,9): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(8,10): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(9,8): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(10,10): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(12,1): error TS1005: ':' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(15,6): error TS1005: ',' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(16,6): error TS1005: ',' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(17,6): error TS1005: '=' expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(18,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(15,5): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(15,7): error TS2304: Cannot find name 'b'.
tests/cases/compiler/objectLiteralShorthandProperties2.ts(16,5): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/objectLiteralShorthandProperties2.ts (17 errors) ====
// errors
var y = {
"stringLiteral",
~
!!! error TS1005: ':' expected.
42,
~
!!! error TS1005: ':' expected.
get e,
~
!!! error TS1005: '(' expected.
~
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
set f,
~
!!! error TS1005: '(' expected.
this,
~
!!! error TS1005: ':' expected.
super,
~
!!! error TS1005: ':' expected.
var,
~
!!! error TS1005: ':' expected.
class,
~
!!! error TS1005: ':' expected.
typeof
};
~
!!! error TS1005: ':' expected.
var x = {
a.b,
~
!!! error TS1005: ',' expected.
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2304: Cannot find name 'b'.
a["ss"],
~
!!! error TS1005: ',' expected.
~
!!! error TS2300: Duplicate identifier 'a'.
a[1],
~
!!! error TS1005: '=' expected.
};
~
!!! error TS1128: Declaration or statement expected.

View file

@ -0,0 +1,30 @@
//// [objectLiteralShorthandProperties3.ts]
// module export
module m {
export var x;
}
module m {
var z = x;
var y = {
a: x,
x
};
}
//// [objectLiteralShorthandProperties3.js]
// module export
var m;
(function (m) {
m.x;
})(m || (m = {}));
var m;
(function (m) {
var z = m.x;
var y = {
a: m.x,
m.x: m.x
};
})(m || (m = {}));

View file

@ -0,0 +1,31 @@
=== tests/cases/compiler/objectLiteralShorthandProperties3.ts ===
// module export
module m {
>m : typeof m
export var x;
>x : any
}
module m {
>m : typeof m
var z = x;
>z : any
>x : any
var y = {
>y : { a: any; x: any; }
>{ a: x, x } : { a: any; x: any; }
a: x,
>a : any
>x : any
x
>x : any
};
}

View file

@ -0,0 +1,11 @@
tests/cases/compiler/objectLiteralShorthandProperties4.ts(3,5): error TS2304: Cannot find name 'undefinedVariable'.
==== tests/cases/compiler/objectLiteralShorthandProperties4.ts (1 errors) ====
var x = {
x, // OK
undefinedVariable // Error
~~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'undefinedVariable'.
}

View file

@ -0,0 +1,12 @@
//// [objectLiteralShorthandProperties4.ts]
var x = {
x, // OK
undefinedVariable // Error
}
//// [objectLiteralShorthandProperties4.js]
var x = {
x: x,
undefinedVariable: undefinedVariable // Error
};

View file

@ -0,0 +1,11 @@
//// [objectLiteralShorthandPropertiesAssignment.ts]
var id: number = 10000;
var name: string = "my name";
var person: { name: string; id: number } = { name, id };
//// [objectLiteralShorthandPropertiesAssignment.js]
var id = 10000;
var name = "my name";
var person = { name: name, id: id };

View file

@ -0,0 +1,15 @@
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts ===
var id: number = 10000;
>id : number
var name: string = "my name";
>name : string
var person: { name: string; id: number } = { name, id };
>person : { name: string; id: number; }
>name : string
>id : number
>{ name, id } : { name: string; id: number; }
>name : string
>id : number

View file

@ -0,0 +1,13 @@
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
Property 'b' is missing in type '{ name: string; id: number; }'.
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts (1 errors) ====
var id: number = 10000;
var name: string = "my name";
var person: { b: string; id: number } = { name, id }; // error
~~~~~~
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'.

View file

@ -0,0 +1,11 @@
//// [objectLiteralShorthandPropertiesAssignment2.ts]
var id: number = 10000;
var name: string = "my name";
var person: { b: string; id: number } = { name, id }; // error
//// [objectLiteralShorthandPropertiesAssignment2.js]
var id = 10000;
var name = "my name";
var person = { name: name, id: id }; // error

View file

@ -0,0 +1,20 @@
//// [objectLiteralShorthandPropertiesFunctionArgument.ts]
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { name: string; id: number }) { }
foo(person);
var obj = { name: name, id: id };
//// [objectLiteralShorthandPropertiesFunctionArgument.js]
var id = 10000;
var name = "my name";
var person = { name: name, id: id };
function foo(p) {
}
foo(person);
var obj = { name: name, id: id };

View file

@ -0,0 +1,33 @@
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesFunctionArgument.ts ===
var id: number = 10000;
>id : number
var name: string = "my name";
>name : string
var person = { name, id };
>person : { name: string; id: number; }
>{ name, id } : { name: string; id: number; }
>name : string
>id : number
function foo(p: { name: string; id: number }) { }
>foo : (p: { name: string; id: number; }) => void
>p : { name: string; id: number; }
>name : string
>id : number
foo(person);
>foo(person) : void
>foo : (p: { name: string; id: number; }) => void
>person : { name: string; id: number; }
var obj = { name: name, id: id };
>obj : { name: string; id: number; }
>{ name: name, id: id } : { name: string; id: number; }
>name : string
>name : string
>id : number
>id : number

View file

@ -0,0 +1,14 @@
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesFunctionArgument2.ts(7,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ a: string; id: number; }'.
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesFunctionArgument2.ts (1 errors) ====
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { a: string; id: number }) { }
foo(person); // error
~~~~~~
!!! error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ a: string; id: number; }'.

View file

@ -0,0 +1,17 @@
//// [objectLiteralShorthandPropertiesFunctionArgument2.ts]
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { a: string; id: number }) { }
foo(person); // error
//// [objectLiteralShorthandPropertiesFunctionArgument2.js]
var id = 10000;
var name = "my name";
var person = { name: name, id: id };
function foo(p) {
}
foo(person); // error

View file

@ -0,0 +1,62 @@
//// [objectLiteralShorthandPropertiesTargetES6.ts]
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
}
var x3 = {
a: 0,
b,
c,
d() { },
x3,
parent: x3
};
module m {
export var x;
}
module m {
var z = x;
var y = {
a: x,
x
};
}
//// [objectLiteralShorthandPropertiesTargetES6.js]
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
};
var x3 = {
a: 0,
b,
c,
d: function () {
},
x3,
parent: x3
};
var m;
(function (m) {
m.x;
})(m || (m = {}));
var m;
(function (m) {
var z = m.x;
var y = {
a: m.x,
m.x
};
})(m || (m = {}));

View file

@ -0,0 +1,77 @@
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts ===
var a, b, c;
>a : any
>b : any
>c : any
var x1 = {
>x1 : { a: any; }
>{ a} : { a: any; }
a
>a : any
};
var x2 = {
>x2 : { a: any; }
>{ a,} : { a: any; }
a,
>a : any
}
var x3 = {
>x3 : any
>{ a: 0, b, c, d() { }, x3, parent: x3} : { a: number; b: any; c: any; d: () => void; x3: any; parent: any; }
a: 0,
>a : number
b,
>b : any
c,
>c : any
d() { },
>d : () => void
>d() { } : () => void
x3,
>x3 : any
parent: x3
>parent : any
>x3 : any
};
module m {
>m : typeof m
export var x;
>x : any
}
module m {
>m : typeof m
var z = x;
>z : any
>x : any
var y = {
>y : { a: any; x: any; }
>{ a: x, x } : { a: any; x: any; }
a: x,
>a : any
>x : any
x
>x : any
};
}

View file

@ -0,0 +1,20 @@
// @target: es5
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
}
var x3 = {
a: 0,
b,
c,
d() { },
x3,
parent: x3
};

View file

@ -0,0 +1,18 @@
// errors
var y = {
"stringLiteral",
42,
get e,
set f,
this,
super,
var,
class,
typeof
};
var x = {
a.b,
a["ss"],
a[1],
};

View file

@ -0,0 +1,13 @@
// module export
module m {
export var x;
}
module m {
var z = x;
var y = {
a: x,
x
};
}

View file

@ -0,0 +1,4 @@
var x = {
x, // OK
undefinedVariable // Error
}

View file

@ -0,0 +1,4 @@
var id: number = 10000;
var name: string = "my name";
var person: { name: string; id: number } = { name, id };

View file

@ -0,0 +1,4 @@
var id: number = 10000;
var name: string = "my name";
var person: { b: string; id: number } = { name, id }; // error

View file

@ -0,0 +1,10 @@
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { name: string; id: number }) { }
foo(person);
var obj = { name: name, id: id };

View file

@ -0,0 +1,7 @@
var id: number = 10000;
var name: string = "my name";
var person = { name, id };
function foo(p: { a: string; id: number }) { }
foo(person); // error

View file

@ -0,0 +1,31 @@
// @target: es6
var a, b, c;
var x1 = {
a
};
var x2 = {
a,
}
var x3 = {
a: 0,
b,
c,
d() { },
x3,
parent: x3
};
module m {
export var x;
}
module m {
var z = x;
var y = {
a: x,
x
};
}