From 41d546719cbf14bbe577fbde456d0f61fc1a2dd0 Mon Sep 17 00:00:00 2001 From: daviss Date: Thu, 28 Mar 2024 16:25:28 -0700 Subject: [PATCH] add test to make use of the recent adjustments This commit adds a test that would fail without the changes in this pull request, such as JvmSuppressWildcard, `Null` class name, and kotlin/java generic name difference --- .../testcases/KT008_funky_names/ChildScope.kt | 26 +++++ .../testcases/KT008_funky_names/GRAPH.txt | 102 ++++++++++++++++++ .../java/testcases/KT008_funky_names/Null.kt | 18 ++++ .../java/testcases/KT008_funky_names/Scope.kt | 68 ++++++++++++ .../testcases/KT008_funky_names/Test.java | 26 +++++ 5 files changed, 240 insertions(+) create mode 100644 tests/src/main/java/testcases/KT008_funky_names/ChildScope.kt create mode 100644 tests/src/main/java/testcases/KT008_funky_names/GRAPH.txt create mode 100644 tests/src/main/java/testcases/KT008_funky_names/Null.kt create mode 100644 tests/src/main/java/testcases/KT008_funky_names/Scope.kt create mode 100644 tests/src/main/java/testcases/KT008_funky_names/Test.java diff --git a/tests/src/main/java/testcases/KT008_funky_names/ChildScope.kt b/tests/src/main/java/testcases/KT008_funky_names/ChildScope.kt new file mode 100644 index 00000000..203445ab --- /dev/null +++ b/tests/src/main/java/testcases/KT008_funky_names/ChildScope.kt @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package testcases.KT008_funky_names + +@motif.Scope +interface ChildScope { + + @motif.Objects + abstract class Objects { + + abstract fun myNull(): Null + } +} \ No newline at end of file diff --git a/tests/src/main/java/testcases/KT008_funky_names/GRAPH.txt b/tests/src/main/java/testcases/KT008_funky_names/GRAPH.txt new file mode 100644 index 00000000..67485f7f --- /dev/null +++ b/tests/src/main/java/testcases/KT008_funky_names/GRAPH.txt @@ -0,0 +1,102 @@ +######################################################################## +# # +# This file is auto-generated by running the Motif compiler tests and # +# serves a as validation of graph correctness. IntelliJ plugin tests # +# also rely on this file to ensure that the plugin graph understanding # +# is equivalent to the compiler's. # +# # +# - Do not edit manually. # +# - Commit changes to source control. # +# - Since this file is autogenerated, code review changes carefully to # +# ensure correctness. # +# # +######################################################################## + + ------- +| Scope | + ------- + + ==== Required ==== + + ==== Provides ==== + + ---- boolean | Objects.myBoolean ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myBoolean() + + ---- byte | Objects.myByte ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myByte() + + ---- char | Objects.myChar ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myChar() + + ---- double | Objects.myDouble ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myDouble() + + ---- float | Objects.myFloat ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myFloat() + + ---- int | Objects.myInt ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myInt() + + ---- Object | Objects.myAny ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myAny() + + ---- Function2 | Objects.function2 ---- + [ Required ] + [ Consumed By ] + * ChildScope | Objects.myNull(function2) + + ---- long | Objects.myLong ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myLong() + + ---- short | Objects.myShort ---- + [ Required ] + [ Consumed By ] + * Scope | Scope.myShort() + + ---- Scope | implicit ---- + [ Required ] + [ Consumed By ] + + ------------ + | ChildScope | + ------------ + + ==== Required ==== + + ---- Function2 ---- + [ Provided By ] + * Scope | Objects.function2 + [ Consumed By ] + * ChildScope | Objects.myNull(function2) + + ==== Provides ==== + + ---- ChildScope | implicit ---- + [ Required ] + [ Consumed By ] + + ---- Null | Objects.myNull ---- + [ Required ] + Function2 + [ Provided By ] + * Scope | Objects.function2 + [ Consumed By ] + + diff --git a/tests/src/main/java/testcases/KT008_funky_names/Null.kt b/tests/src/main/java/testcases/KT008_funky_names/Null.kt new file mode 100644 index 00000000..a9926dec --- /dev/null +++ b/tests/src/main/java/testcases/KT008_funky_names/Null.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package testcases.KT008_funky_names + +class Null(function2: @JvmSuppressWildcards ((Long, Double) -> Short)) \ No newline at end of file diff --git a/tests/src/main/java/testcases/KT008_funky_names/Scope.kt b/tests/src/main/java/testcases/KT008_funky_names/Scope.kt new file mode 100644 index 00000000..8204c0c4 --- /dev/null +++ b/tests/src/main/java/testcases/KT008_funky_names/Scope.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package testcases.KT008_funky_names + +import motif.Expose + + +@motif.Scope +interface Scope { + + fun child(): ChildScope + + fun myByte(): Byte + + fun myShort(): Short + + fun myInt(): Int + + fun myLong(): Long + + fun myFloat(): Float + + fun myDouble(): Double + + fun myBoolean(): Boolean + + fun myChar(): Char + + fun myAny(): Any + + @motif.Objects + open class Objects { + + @Expose + fun function2(): ((Long, Double) -> Short) = { _, d -> d.toInt().toShort() } + + fun myByte(): Byte = 3 + + fun myShort(): Short = 3 + + fun myInt(): Int = 3 + + fun myLong(): Long = 3 + + fun myFloat(): Float = 0.2f + + fun myDouble(): Double = 0.2 + + fun myBoolean(): Boolean = true + + fun myChar(): Char = 'c' + + fun myAny(): Any = Any() + } +} \ No newline at end of file diff --git a/tests/src/main/java/testcases/KT008_funky_names/Test.java b/tests/src/main/java/testcases/KT008_funky_names/Test.java new file mode 100644 index 00000000..bf8c3735 --- /dev/null +++ b/tests/src/main/java/testcases/KT008_funky_names/Test.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package testcases.KT008_funky_names; + +import static com.google.common.truth.Truth.assertThat; + +public class Test { + + public static void run() { + Scope scope = new ScopeImpl(); + assertThat(scope.child()).isNotNull(); + } +}