Skip to content

Commit 5decea6

Browse files
broadwaylambSpace Team
authored andcommitted
[test] Test parameter names in function types in TypeScript export tests
1 parent 94f3ef4 commit 5decea6

File tree

14 files changed

+38
-24
lines changed

14 files changed

+38
-24
lines changed

js/js.translator/testData/typescript-export/js/functions-in-exported-file/functions.aa.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ declare namespace JS_TESTS {
3636
function concatWithContextParameters(scope1: foo.Scope1, scope2: foo.Scope2): string;
3737
function concatWithExtensionAndContextParameter(scope1: foo.Scope1, _this_: foo.Scope2): string;
3838
function getWithExtension(_this_: foo.Scope1): string;
39-
function context<A, B, R>(a: A, b: B, block: (p0: A, p1: B) => R): R;
39+
function allParameters<A, B, C, D, R>(a: A, b: B, c: C, d: D, block: (p0: A, p1: B, p2: C, p3: D) => R): R;
4040
/* ErrorDeclaration: Class declarations are not implemented yet */
4141
/* ErrorDeclaration: Class declarations are not implemented yet */
4242
/* ErrorDeclaration: Class declarations are not implemented yet */

js/js.translator/testData/typescript-export/js/functions-in-exported-file/functions.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ declare namespace JS_TESTS {
6868
function concatWithContextParameters(scope1: foo.Scope1, scope2: foo.Scope2): string;
6969
function concatWithExtensionAndContextParameter(scope1: foo.Scope1, _this_: foo.Scope2): string;
7070
function getWithExtension(_this_: foo.Scope1): string;
71-
function context<A, B, R>(a: A, b: B, block: (p0: A, p1: B) => R): R;
71+
function allParameters<A, B, C, D, R>(a: A, b: B, c: C, d: D, block: (p0: A, p1: B, p2: C, p3: D) => R): R;
7272
}
7373
}

js/js.translator/testData/typescript-export/js/functions-in-exported-file/functions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ fun Scope2.concatWithExtensionAndContextParameter() = scope1.getA() + getA()
140140
fun Scope1.getWithExtension() = getA()
141141

142142

143-
fun <A, B, R> context(a: A, b: B, block: context(A, B) () -> R): R = block(a, b)
143+
fun <A, B, C, D, R> allParameters(a: A, b: B, c: C, d: D, block: context(A, B) C.(d: D) -> R): R = block(a, b, c, d)

js/js.translator/testData/typescript-export/js/functions-in-exported-file/functions__main.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Scope1 = JS_TESTS.foo.Scope1;
2626
import Scope2 = JS_TESTS.foo.Scope2;
2727
import concatWithExtensionAndContextParameter = JS_TESTS.foo.concatWithExtensionAndContextParameter;
2828
import getWithExtension = JS_TESTS.foo.getWithExtension;
29-
import context = JS_TESTS.foo.context;
29+
import allParameters = JS_TESTS.foo.allParameters;
3030

3131
function assert(condition: boolean) {
3232
if (!condition) {
@@ -94,8 +94,15 @@ function box(): string {
9494

9595
assert(getWithExtension(new Scope1("A")) == "A")
9696

97-
assert(context(new Scope1("A"), new Scope2("B"), concatWithContextParameters) == "AB")
98-
assert(context(new Scope1("B"), new Scope2("A"), concatWithContextParameters) == "BA")
97+
assert(
98+
allParameters(
99+
new Scope1("A"),
100+
new Scope2("B"),
101+
"C",
102+
"D",
103+
(a, b, c, d) => concatWithContextParameters(a, b) + c + d
104+
) == "ABCD"
105+
)
99106

100107
return "OK";
101108
}

js/js.translator/testData/typescript-export/js/functions/functions.aa.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ declare namespace JS_TESTS {
3636
function concatWithContextParameters(scope1: foo.Scope1, scope2: foo.Scope2): string;
3737
function concatWithExtensionAndContextParameter(scope1: foo.Scope1, _this_: foo.Scope2): string;
3838
function getWithExtension(_this_: foo.Scope1): string;
39-
function context<A, B, R>(a: A, b: B, block: (p0: A, p1: B) => R): R;
39+
function allParameters<A, B, C, D, R>(a: A, b: B, c: C, d: D, block: (p0: A, p1: B, p2: C, p3: D) => R): R;
4040
/* ErrorDeclaration: Class declarations are not implemented yet */
4141
/* ErrorDeclaration: Class declarations are not implemented yet */
4242
/* ErrorDeclaration: Class declarations are not implemented yet */

js/js.translator/testData/typescript-export/js/functions/functions.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ declare namespace JS_TESTS {
6868
function concatWithContextParameters(scope1: foo.Scope1, scope2: foo.Scope2): string;
6969
function concatWithExtensionAndContextParameter(scope1: foo.Scope1, _this_: foo.Scope2): string;
7070
function getWithExtension(_this_: foo.Scope1): string;
71-
function context<A, B, R>(a: A, b: B, block: (p0: A, p1: B) => R): R;
71+
function allParameters<A, B, C, D, R>(a: A, b: B, c: C, d: D, block: (p0: A, p1: B, p2: C, p3: D) => R): R;
7272
}
7373
}

js/js.translator/testData/typescript-export/js/functions/functions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ fun Scope2.concatWithExtensionAndContextParameter() = scope1.getA() + getA()
135135
fun Scope1.getWithExtension() = getA()
136136

137137
@JsExport
138-
fun <A, B, R> context(a: A, b: B, block: context(A, B) () -> R): R = block(a, b)
138+
fun <A, B, C, D, R> allParameters(a: A, b: B, c: C, d: D, block: context(A, B) C.(d: D) -> R): R = block(a, b, c, d)

js/js.translator/testData/typescript-export/js/functions/functions__main.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Scope1 = JS_TESTS.foo.Scope1;
2626
import Scope2 = JS_TESTS.foo.Scope2;
2727
import concatWithExtensionAndContextParameter = JS_TESTS.foo.concatWithExtensionAndContextParameter;
2828
import getWithExtension = JS_TESTS.foo.getWithExtension;
29-
import context = JS_TESTS.foo.context;
29+
import allParameters = JS_TESTS.foo.allParameters;
3030

3131
function assert(condition: boolean) {
3232
if (!condition) {
@@ -94,8 +94,15 @@ function box(): string {
9494

9595
assert(getWithExtension(new Scope1("A")) == "A")
9696

97-
assert(context(new Scope1("A"), new Scope2("B"), concatWithContextParameters) == "AB")
98-
assert(context(new Scope1("B"), new Scope2("A"), concatWithContextParameters) == "BA")
97+
assert(
98+
allParameters(
99+
new Scope1("A"),
100+
new Scope2("B"),
101+
"C",
102+
"D",
103+
(a, b, c, d) => concatWithContextParameters(a, b) + c + d
104+
) == "ABCD"
105+
)
99106

100107
return "OK";
101108
}

js/js.translator/testData/typescript-export/js/primitives-in-exported-file/primitives.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@ val _n_array_n_int: Array<Int?>? = emptyArray()
154154
val _array_n_array_string: Array<Array<String>?> = arrayOf(arrayOf(":)"))
155155

156156

157-
val _fun_n_int_unit: (Int?) -> Unit = { x -> }
157+
val _fun_n_int_unit: (int: Int?) -> Unit = { x -> }
158158

159159

160-
val _fun_n_int_unit_class: Function1<Int?, Unit> = { x -> }
160+
val _fun_n_int_unit_class: Function1<@ParameterName("int") Int?, Unit> = { x -> }
161161

162162

163163
val _kfun_n_int_unit: kotlin.reflect.KFunction1<Int?, Unit> = _fun_n_int_unit_class::invoke
164164

165165

166-
val _fun_n_int_unit_suspend: suspend (Int?) -> Unit = { x -> }
166+
val _fun_n_int_unit_suspend: suspend (int: Int?) -> Unit = { x -> }
167167

168168

169-
val _fun_n_int_unit_suspend_class: kotlin.coroutines.SuspendFunction1<Int?, Unit> = { x -> }
169+
val _fun_n_int_unit_suspend_class: kotlin.coroutines.SuspendFunction1<@ParameterName("int") Int?, Unit> = { x -> }
170170

171171

172172
val _kfun_n_int_unit_suspend: kotlin.reflect.KSuspendFunction1<Int?, Unit> = _fun_n_int_unit_suspend::invoke

js/js.translator/testData/typescript-export/js/primitives/primitives.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,19 @@ val _n_array_n_int: Array<Int?>? = emptyArray()
149149
val _array_n_array_string: Array<Array<String>?> = arrayOf(arrayOf(":)"))
150150

151151
@JsExport
152-
val _fun_n_int_unit: (Int?) -> Unit = { x -> }
152+
val _fun_n_int_unit: (int: Int?) -> Unit = { x -> }
153153

154154
@JsExport
155-
val _fun_n_int_unit_class: Function1<Int?, Unit> = { x -> }
155+
val _fun_n_int_unit_class: Function1<@ParameterName("int") Int?, Unit> = { x -> }
156156

157157
@JsExport
158158
val _kfun_n_int_unit: kotlin.reflect.KFunction1<Int?, Unit> = _fun_n_int_unit_class::invoke
159159

160160
@JsExport
161-
val _fun_n_int_unit_suspend: suspend (Int?) -> Unit = { x -> }
161+
val _fun_n_int_unit_suspend: suspend (int: Int?) -> Unit = { x -> }
162162

163163
@JsExport
164-
val _fun_n_int_unit_suspend_class: kotlin.coroutines.SuspendFunction1<Int?, Unit> = { x -> }
164+
val _fun_n_int_unit_suspend_class: kotlin.coroutines.SuspendFunction1<@ParameterName("int") Int?, Unit> = { x -> }
165165

166166
@JsExport
167167
val _kfun_n_int_unit_suspend: kotlin.reflect.KSuspendFunction1<Int?, Unit> = _fun_n_int_unit_suspend::invoke

0 commit comments

Comments
 (0)