Skip to content

Commit 4a0af76

Browse files
committed
Add tests for iterator spread in call
1 parent 376574d commit 4a0af76

36 files changed

+1310
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target.
2+
3+
4+
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ====
5+
foo(...new SymbolIterator);
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
!!! error TS2346: Supplied parameters do not match any signature of call target.
8+
9+
function foo(s: symbol) { }
10+
class SymbolIterator {
11+
next() {
12+
return {
13+
value: Symbol(),
14+
done: false
15+
};
16+
}
17+
18+
[Symbol.iterator]() {
19+
return this;
20+
}
21+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//// [iteratorSpreadInCall.ts]
2+
foo(...new SymbolIterator);
3+
4+
function foo(s: symbol) { }
5+
class SymbolIterator {
6+
next() {
7+
return {
8+
value: Symbol(),
9+
done: false
10+
};
11+
}
12+
13+
[Symbol.iterator]() {
14+
return this;
15+
}
16+
}
17+
18+
//// [iteratorSpreadInCall.js]
19+
foo(...new SymbolIterator);
20+
function foo(s) {
21+
}
22+
class SymbolIterator {
23+
next() {
24+
return {
25+
value: Symbol(),
26+
done: false
27+
};
28+
}
29+
[Symbol.iterator]() {
30+
return this;
31+
}
32+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target.
2+
3+
4+
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ====
5+
foo(...new SymbolIterator);
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
!!! error TS2346: Supplied parameters do not match any signature of call target.
8+
9+
function foo<T>(s: T[]) { return s[0] }
10+
11+
class SymbolIterator {
12+
next() {
13+
return {
14+
value: Symbol(),
15+
done: false
16+
};
17+
}
18+
19+
[Symbol.iterator]() {
20+
return this;
21+
}
22+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [iteratorSpreadInCall10.ts]
2+
foo(...new SymbolIterator);
3+
4+
function foo<T>(s: T[]) { return s[0] }
5+
6+
class SymbolIterator {
7+
next() {
8+
return {
9+
value: Symbol(),
10+
done: false
11+
};
12+
}
13+
14+
[Symbol.iterator]() {
15+
return this;
16+
}
17+
}
18+
19+
//// [iteratorSpreadInCall10.js]
20+
foo(...new SymbolIterator);
21+
function foo(s) {
22+
return s[0];
23+
}
24+
class SymbolIterator {
25+
next() {
26+
return {
27+
value: Symbol(),
28+
done: false
29+
};
30+
}
31+
[Symbol.iterator]() {
32+
return this;
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [iteratorSpreadInCall11.ts]
2+
foo(...new SymbolIterator);
3+
4+
function foo<T>(...s: T[]) { return s[0] }
5+
6+
class SymbolIterator {
7+
next() {
8+
return {
9+
value: Symbol(),
10+
done: false
11+
};
12+
}
13+
14+
[Symbol.iterator]() {
15+
return this;
16+
}
17+
}
18+
19+
//// [iteratorSpreadInCall11.js]
20+
foo(...new SymbolIterator);
21+
function foo(...s) {
22+
return s[0];
23+
}
24+
class SymbolIterator {
25+
next() {
26+
return {
27+
value: Symbol(),
28+
done: false
29+
};
30+
}
31+
[Symbol.iterator]() {
32+
return this;
33+
}
34+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
=== tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts ===
2+
foo(...new SymbolIterator);
3+
>foo(...new SymbolIterator) : symbol
4+
>foo : <T>(...s: T[]) => T
5+
>...new SymbolIterator : symbol
6+
>new SymbolIterator : SymbolIterator
7+
>SymbolIterator : typeof SymbolIterator
8+
9+
function foo<T>(...s: T[]) { return s[0] }
10+
>foo : <T>(...s: T[]) => T
11+
>T : T
12+
>s : T[]
13+
>T : T
14+
>s[0] : T
15+
>s : T[]
16+
17+
class SymbolIterator {
18+
>SymbolIterator : SymbolIterator
19+
20+
next() {
21+
>next : () => { value: symbol; done: boolean; }
22+
23+
return {
24+
>{ value: Symbol(), done: false } : { value: symbol; done: boolean; }
25+
26+
value: Symbol(),
27+
>value : symbol
28+
>Symbol() : symbol
29+
>Symbol : SymbolConstructor
30+
31+
done: false
32+
>done : boolean
33+
34+
};
35+
}
36+
37+
[Symbol.iterator]() {
38+
>Symbol.iterator : symbol
39+
>Symbol : SymbolConstructor
40+
>iterator : symbol
41+
42+
return this;
43+
>this : SymbolIterator
44+
}
45+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//// [iteratorSpreadInCall12.ts]
2+
new Foo(...[...new SymbolIterator, ...[...new StringIterator]]);
3+
4+
class Foo<T> {
5+
constructor(...s: T[]) { }
6+
}
7+
8+
class SymbolIterator {
9+
next() {
10+
return {
11+
value: Symbol(),
12+
done: false
13+
};
14+
}
15+
16+
[Symbol.iterator]() {
17+
return this;
18+
}
19+
}
20+
21+
class StringIterator {
22+
next() {
23+
return {
24+
value: "",
25+
done: false
26+
};
27+
}
28+
29+
[Symbol.iterator]() {
30+
return this;
31+
}
32+
}
33+
34+
//// [iteratorSpreadInCall12.js]
35+
new Foo(...[
36+
...new SymbolIterator,
37+
...[
38+
...new StringIterator
39+
]
40+
]);
41+
class Foo {
42+
constructor(...s) {
43+
}
44+
}
45+
class SymbolIterator {
46+
next() {
47+
return {
48+
value: Symbol(),
49+
done: false
50+
};
51+
}
52+
[Symbol.iterator]() {
53+
return this;
54+
}
55+
}
56+
class StringIterator {
57+
next() {
58+
return {
59+
value: "",
60+
done: false
61+
};
62+
}
63+
[Symbol.iterator]() {
64+
return this;
65+
}
66+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
=== tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts ===
2+
new Foo(...[...new SymbolIterator, ...[...new StringIterator]]);
3+
>new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo<string | symbol>
4+
>Foo : typeof Foo
5+
>...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol
6+
>[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[]
7+
>...new SymbolIterator : symbol
8+
>new SymbolIterator : SymbolIterator
9+
>SymbolIterator : typeof SymbolIterator
10+
>...[...new StringIterator] : string
11+
>[...new StringIterator] : string[]
12+
>...new StringIterator : string
13+
>new StringIterator : StringIterator
14+
>StringIterator : typeof StringIterator
15+
16+
class Foo<T> {
17+
>Foo : Foo<T>
18+
>T : T
19+
20+
constructor(...s: T[]) { }
21+
>s : T[]
22+
>T : T
23+
}
24+
25+
class SymbolIterator {
26+
>SymbolIterator : SymbolIterator
27+
28+
next() {
29+
>next : () => { value: symbol; done: boolean; }
30+
31+
return {
32+
>{ value: Symbol(), done: false } : { value: symbol; done: boolean; }
33+
34+
value: Symbol(),
35+
>value : symbol
36+
>Symbol() : symbol
37+
>Symbol : SymbolConstructor
38+
39+
done: false
40+
>done : boolean
41+
42+
};
43+
}
44+
45+
[Symbol.iterator]() {
46+
>Symbol.iterator : symbol
47+
>Symbol : SymbolConstructor
48+
>iterator : symbol
49+
50+
return this;
51+
>this : SymbolIterator
52+
}
53+
}
54+
55+
class StringIterator {
56+
>StringIterator : StringIterator
57+
58+
next() {
59+
>next : () => { value: string; done: boolean; }
60+
61+
return {
62+
>{ value: "", done: false } : { value: string; done: boolean; }
63+
64+
value: "",
65+
>value : string
66+
67+
done: false
68+
>done : boolean
69+
70+
};
71+
}
72+
73+
[Symbol.iterator]() {
74+
>Symbol.iterator : symbol
75+
>Symbol : SymbolConstructor
76+
>iterator : symbol
77+
78+
return this;
79+
>this : StringIterator
80+
}
81+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target.
2+
3+
4+
==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ====
5+
foo(...new SymbolIterator);
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
!!! error TS2346: Supplied parameters do not match any signature of call target.
8+
9+
function foo(s: symbol[]) { }
10+
class SymbolIterator {
11+
next() {
12+
return {
13+
value: Symbol(),
14+
done: false
15+
};
16+
}
17+
18+
[Symbol.iterator]() {
19+
return this;
20+
}
21+
}

0 commit comments

Comments
 (0)