Skip to content

Commit 5874329

Browse files
committed
tests: add a few tests for empty tuples and more nullable tests
1 parent dda5084 commit 5874329

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

tests/parser/tuple.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function tuple0(): [] { return []; }
12
function tuple1(): [i32, i32] { return [1, 2]; }
23
function tuple2(): [i32, [i32, i32]] { return [1, [2, 3]]; }
34
function tuple3(): [i32, string] { return [1, "a"]; }
@@ -7,15 +8,19 @@ function tuple6(): [[i32[]]] { return [[[1, 2]]]; }
78
function tuple7(): [x: i32, y: i32] { return [1, 2]; }
89
function tuple8(): [head: i32, tail: [lo: i32, hi: i32]] { return [1, [2, 3]]; }
910

10-
function func1(a: i32, b: i32): [i32, i32] { return [a, b]; }
11+
function func0(x: []): [] { return []; }
12+
function func1(x: i32, y: i32): [i32, i32] { return [y, x]; }
1113
function func2(x: [i32, i32]): [i32, i32] { return x; }
1214
function func3(x: [i32, [i32, i32]], y: i32): [i32, [i32, i32]] { return x; }
1315
function func4(x: readonly [i32, string]): [void] { return [void(0)]; }
1416
function func5(x: readonly [Array<i32>, i32[]]): readonly [i32] { return [x[1].length]; }
1517
function func6(x: [i32, i32] | null): [i32, i32] | null { return x; }
1618
function func7(x: readonly [[i32[]], [string]]): readonly [[i32[]], [string]] { return x; }
1719
function func8(x: [left: i32, right: i32]): [first: i32, second: i32] { return x; }
20+
function func9<T>(x: [T, T, i32]): [T] { return x; }
21+
function func10(x: [string | null, i32] | null): [string | null, i32] | null { return x; }
1822

23+
type type0 = [];
1924
type type1 = [i32, i32];
2025
type type2 = [i32, [i32, i32]];
2126
type type3 = readonly [i32, string];

tests/parser/tuple.ts.fixture.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
function tuple0(): [] {
2+
return [];
3+
}
14
function tuple1(): [i32, i32] {
25
return [1, 2];
36
}
@@ -22,8 +25,11 @@ function tuple7(): [x: i32, y: i32] {
2225
function tuple8(): [head: i32, tail: [lo: i32, hi: i32]] {
2326
return [1, [2, 3]];
2427
}
25-
function func1(a: i32, b: i32): [i32, i32] {
26-
return [a, b];
28+
function func0(x: []): [] {
29+
return [];
30+
}
31+
function func1(x: i32, y: i32): [i32, i32] {
32+
return [y, x];
2733
}
2834
function func2(x: [i32, i32]): [i32, i32] {
2935
return x;
@@ -46,6 +52,13 @@ function func7(x: Readonly<[[Array<i32>], [string]]>): Readonly<[[Array<i32>], [
4652
function func8(x: [left: i32, right: i32]): [first: i32, second: i32] {
4753
return x;
4854
}
55+
function func9<T>(x: [T, T, i32]): [T] {
56+
return x;
57+
}
58+
function func10(x: [string | null, i32] | null): [string | null, i32] | null {
59+
return x;
60+
}
61+
type type0 = [];
4962
type type1 = [i32, i32];
5063
type type2 = [i32, [i32, i32]];
5164
type type3 = Readonly<[i32, string]>;

0 commit comments

Comments
 (0)