Move strict tuple test and add a couple of cases
This commit is contained in:
parent
5d7e87a9c2
commit
defd32f015
7 changed files with 139 additions and 88 deletions
37
tests/baselines/reference/strictTupleLength.errors.txt
Normal file
37
tests/baselines/reference/strictTupleLength.errors.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
tests/cases/conformance/types/tuple/strictTupleLength.ts(1,9): error TS1122: A tuple type element list cannot be empty.
|
||||
tests/cases/conformance/types/tuple/strictTupleLength.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't1' has type '[number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 1:4, but here has type '[number, number]'.
|
||||
tests/cases/conformance/types/tuple/strictTupleLength.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't2' has type '[number, number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 2:4, but here has type '[number]'.
|
||||
tests/cases/conformance/types/tuple/strictTupleLength.ts(18,1): error TS2322: Type 'number[]' is not assignable to type '[number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/tuple/strictTupleLength.ts (4 errors) ====
|
||||
var t0: [];
|
||||
~~
|
||||
!!! error TS1122: A tuple type element list cannot be empty.
|
||||
var t1: [number];
|
||||
var t2: [number, number];
|
||||
var arr: number[];
|
||||
|
||||
var len0: 0 = t0.length;
|
||||
var len1: 1 = t1.length;
|
||||
var len2: 2 = t2.length;
|
||||
var lena: number = arr.length;
|
||||
|
||||
var t1 = t2; // error
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't1' has type '[number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 1:4, but here has type '[number, number]'.
|
||||
var t2 = t1; // error
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't2' has type '[number, number]' at tests/cases/conformance/types/tuple/strictTupleLength.ts 2:4, but here has type '[number]'.
|
||||
|
||||
type A<T extends any[]> = T['length'];
|
||||
var b: A<[boolean]>;
|
||||
var c: 1 = b;
|
||||
|
||||
t1 = arr; // error with or without strict
|
||||
~~
|
||||
!!! error TS2322: Type 'number[]' is not assignable to type '[number]'.
|
||||
!!! error TS2322: Property '0' is missing in type 'number[]'.
|
||||
arr = t1; // ok with or without strict
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
//// [tupleLength.ts]
|
||||
// var t0: [];
|
||||
//// [strictTupleLength.ts]
|
||||
var t0: [];
|
||||
var t1: [number];
|
||||
var t2: [number, number];
|
||||
var arr: number[];
|
||||
|
||||
// var len0: 0 = t0.length;
|
||||
var len0: 0 = t0.length;
|
||||
var len1: 1 = t1.length;
|
||||
var len2: 2 = t2.length;
|
||||
var lena: number = arr.length;
|
||||
|
@ -15,14 +15,17 @@ var t2 = t1; // error
|
|||
type A<T extends any[]> = T['length'];
|
||||
var b: A<[boolean]>;
|
||||
var c: 1 = b;
|
||||
|
||||
t1 = arr; // error with or without strict
|
||||
arr = t1; // ok with or without strict
|
||||
|
||||
|
||||
//// [tupleLength.js]
|
||||
// var t0: [];
|
||||
//// [strictTupleLength.js]
|
||||
var t0;
|
||||
var t1;
|
||||
var t2;
|
||||
var arr;
|
||||
// var len0: 0 = t0.length;
|
||||
var len0 = t0.length;
|
||||
var len1 = t1.length;
|
||||
var len2 = t2.length;
|
||||
var lena = arr.length;
|
||||
|
@ -30,3 +33,5 @@ var t1 = t2; // error
|
|||
var t2 = t1; // error
|
||||
var b;
|
||||
var c = b;
|
||||
t1 = arr; // error with or without strict
|
||||
arr = t1; // ok with or without strict
|
66
tests/baselines/reference/strictTupleLength.symbols
Normal file
66
tests/baselines/reference/strictTupleLength.symbols
Normal file
|
@ -0,0 +1,66 @@
|
|||
=== tests/cases/conformance/types/tuple/strictTupleLength.ts ===
|
||||
var t0: [];
|
||||
>t0 : Symbol(t0, Decl(strictTupleLength.ts, 0, 3))
|
||||
|
||||
var t1: [number];
|
||||
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
|
||||
|
||||
var t2: [number, number];
|
||||
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
|
||||
|
||||
var arr: number[];
|
||||
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
|
||||
|
||||
var len0: 0 = t0.length;
|
||||
>len0 : Symbol(len0, Decl(strictTupleLength.ts, 5, 3))
|
||||
>t0.length : Symbol(length)
|
||||
>t0 : Symbol(t0, Decl(strictTupleLength.ts, 0, 3))
|
||||
>length : Symbol(length)
|
||||
|
||||
var len1: 1 = t1.length;
|
||||
>len1 : Symbol(len1, Decl(strictTupleLength.ts, 6, 3))
|
||||
>t1.length : Symbol(length)
|
||||
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
|
||||
>length : Symbol(length)
|
||||
|
||||
var len2: 2 = t2.length;
|
||||
>len2 : Symbol(len2, Decl(strictTupleLength.ts, 7, 3))
|
||||
>t2.length : Symbol(length)
|
||||
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
|
||||
>length : Symbol(length)
|
||||
|
||||
var lena: number = arr.length;
|
||||
>lena : Symbol(lena, Decl(strictTupleLength.ts, 8, 3))
|
||||
>arr.length : Symbol(Array.length, Decl(lib.d.ts, --, --))
|
||||
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
|
||||
>length : Symbol(Array.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
var t1 = t2; // error
|
||||
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
|
||||
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
|
||||
|
||||
var t2 = t1; // error
|
||||
>t2 : Symbol(t2, Decl(strictTupleLength.ts, 2, 3), Decl(strictTupleLength.ts, 11, 3))
|
||||
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
|
||||
|
||||
type A<T extends any[]> = T['length'];
|
||||
>A : Symbol(A, Decl(strictTupleLength.ts, 11, 12))
|
||||
>T : Symbol(T, Decl(strictTupleLength.ts, 13, 7))
|
||||
>T : Symbol(T, Decl(strictTupleLength.ts, 13, 7))
|
||||
|
||||
var b: A<[boolean]>;
|
||||
>b : Symbol(b, Decl(strictTupleLength.ts, 14, 3))
|
||||
>A : Symbol(A, Decl(strictTupleLength.ts, 11, 12))
|
||||
|
||||
var c: 1 = b;
|
||||
>c : Symbol(c, Decl(strictTupleLength.ts, 15, 3))
|
||||
>b : Symbol(b, Decl(strictTupleLength.ts, 14, 3))
|
||||
|
||||
t1 = arr; // error with or without strict
|
||||
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
|
||||
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
|
||||
|
||||
arr = t1; // ok with or without strict
|
||||
>arr : Symbol(arr, Decl(strictTupleLength.ts, 3, 3))
|
||||
>t1 : Symbol(t1, Decl(strictTupleLength.ts, 1, 3), Decl(strictTupleLength.ts, 10, 3))
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
=== tests/cases/compiler/tupleLength.ts ===
|
||||
// var t0: [];
|
||||
=== tests/cases/conformance/types/tuple/strictTupleLength.ts ===
|
||||
var t0: [];
|
||||
>t0 : []
|
||||
|
||||
var t1: [number];
|
||||
>t1 : [number]
|
||||
|
||||
|
@ -9,7 +11,12 @@ var t2: [number, number];
|
|||
var arr: number[];
|
||||
>arr : number[]
|
||||
|
||||
// var len0: 0 = t0.length;
|
||||
var len0: 0 = t0.length;
|
||||
>len0 : 0
|
||||
>t0.length : 0
|
||||
>t0 : []
|
||||
>length : 0
|
||||
|
||||
var len1: 1 = t1.length;
|
||||
>len1 : 1
|
||||
>t1.length : 1
|
||||
|
@ -49,3 +56,13 @@ var c: 1 = b;
|
|||
>c : 1
|
||||
>b : 1
|
||||
|
||||
t1 = arr; // error with or without strict
|
||||
>t1 = arr : number[]
|
||||
>t1 : [number]
|
||||
>arr : number[]
|
||||
|
||||
arr = t1; // ok with or without strict
|
||||
>arr = t1 : [number]
|
||||
>arr : number[]
|
||||
>t1 : [number]
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
tests/cases/compiler/tupleLength.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't1' has type '[number]' at tests/cases/compiler/tupleLength.ts 1:4, but here has type '[number, number]'.
|
||||
tests/cases/compiler/tupleLength.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 't2' has type '[number, number]' at tests/cases/compiler/tupleLength.ts 2:4, but here has type '[number]'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/tupleLength.ts (2 errors) ====
|
||||
// var t0: [];
|
||||
var t1: [number];
|
||||
var t2: [number, number];
|
||||
var arr: number[];
|
||||
|
||||
// var len0: 0 = t0.length;
|
||||
var len1: 1 = t1.length;
|
||||
var len2: 2 = t2.length;
|
||||
var lena: number = arr.length;
|
||||
|
||||
var t1 = t2; // error
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't1' has type '[number]' at tests/cases/compiler/tupleLength.ts 1:4, but here has type '[number, number]'.
|
||||
var t2 = t1; // error
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't2' has type '[number, number]' at tests/cases/compiler/tupleLength.ts 2:4, but here has type '[number]'.
|
||||
|
||||
type A<T extends any[]> = T['length'];
|
||||
var b: A<[boolean]>;
|
||||
var c: 1 = b;
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
=== tests/cases/compiler/tupleLength.ts ===
|
||||
// var t0: [];
|
||||
var t1: [number];
|
||||
>t1 : Symbol(t1, Decl(tupleLength.ts, 1, 3), Decl(tupleLength.ts, 10, 3))
|
||||
|
||||
var t2: [number, number];
|
||||
>t2 : Symbol(t2, Decl(tupleLength.ts, 2, 3), Decl(tupleLength.ts, 11, 3))
|
||||
|
||||
var arr: number[];
|
||||
>arr : Symbol(arr, Decl(tupleLength.ts, 3, 3))
|
||||
|
||||
// var len0: 0 = t0.length;
|
||||
var len1: 1 = t1.length;
|
||||
>len1 : Symbol(len1, Decl(tupleLength.ts, 6, 3))
|
||||
>t1.length : Symbol(length)
|
||||
>t1 : Symbol(t1, Decl(tupleLength.ts, 1, 3), Decl(tupleLength.ts, 10, 3))
|
||||
>length : Symbol(length)
|
||||
|
||||
var len2: 2 = t2.length;
|
||||
>len2 : Symbol(len2, Decl(tupleLength.ts, 7, 3))
|
||||
>t2.length : Symbol(length)
|
||||
>t2 : Symbol(t2, Decl(tupleLength.ts, 2, 3), Decl(tupleLength.ts, 11, 3))
|
||||
>length : Symbol(length)
|
||||
|
||||
var lena: number = arr.length;
|
||||
>lena : Symbol(lena, Decl(tupleLength.ts, 8, 3))
|
||||
>arr.length : Symbol(Array.length, Decl(lib.d.ts, --, --))
|
||||
>arr : Symbol(arr, Decl(tupleLength.ts, 3, 3))
|
||||
>length : Symbol(Array.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
var t1 = t2; // error
|
||||
>t1 : Symbol(t1, Decl(tupleLength.ts, 1, 3), Decl(tupleLength.ts, 10, 3))
|
||||
>t2 : Symbol(t2, Decl(tupleLength.ts, 2, 3), Decl(tupleLength.ts, 11, 3))
|
||||
|
||||
var t2 = t1; // error
|
||||
>t2 : Symbol(t2, Decl(tupleLength.ts, 2, 3), Decl(tupleLength.ts, 11, 3))
|
||||
>t1 : Symbol(t1, Decl(tupleLength.ts, 1, 3), Decl(tupleLength.ts, 10, 3))
|
||||
|
||||
type A<T extends any[]> = T['length'];
|
||||
>A : Symbol(A, Decl(tupleLength.ts, 11, 12))
|
||||
>T : Symbol(T, Decl(tupleLength.ts, 13, 7))
|
||||
>T : Symbol(T, Decl(tupleLength.ts, 13, 7))
|
||||
|
||||
var b: A<[boolean]>;
|
||||
>b : Symbol(b, Decl(tupleLength.ts, 14, 3))
|
||||
>A : Symbol(A, Decl(tupleLength.ts, 11, 12))
|
||||
|
||||
var c: 1 = b;
|
||||
>c : Symbol(c, Decl(tupleLength.ts, 15, 3))
|
||||
>b : Symbol(b, Decl(tupleLength.ts, 14, 3))
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
// @strictTuples: true
|
||||
|
||||
// var t0: [];
|
||||
var t0: [];
|
||||
var t1: [number];
|
||||
var t2: [number, number];
|
||||
var arr: number[];
|
||||
|
||||
// var len0: 0 = t0.length;
|
||||
var len0: 0 = t0.length;
|
||||
var len1: 1 = t1.length;
|
||||
var len2: 2 = t2.length;
|
||||
var lena: number = arr.length;
|
||||
|
@ -16,3 +16,6 @@ var t2 = t1; // error
|
|||
type A<T extends any[]> = T['length'];
|
||||
var b: A<[boolean]>;
|
||||
var c: 1 = b;
|
||||
|
||||
t1 = arr; // error with or without strict
|
||||
arr = t1; // ok with or without strict
|
Loading…
Reference in a new issue