From 513a76c537fa958207a05aa4c1c34ff68e7f18ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0pan=C4=9Bl?= Date: Tue, 14 May 2024 11:22:26 +0200 Subject: [PATCH] Add PathDependentTypeTest --- .../surface/PathDependentTypeTest.scala | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 airframe-surface/src/test/scala/wvlet/airframe/surface/PathDependentTypeTest.scala diff --git a/airframe-surface/src/test/scala/wvlet/airframe/surface/PathDependentTypeTest.scala b/airframe-surface/src/test/scala/wvlet/airframe/surface/PathDependentTypeTest.scala new file mode 100644 index 000000000..24410996f --- /dev/null +++ b/airframe-surface/src/test/scala/wvlet/airframe/surface/PathDependentTypeTest.scala @@ -0,0 +1,44 @@ +/* + * 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 wvlet.airframe.surface + +import wvlet.airspec.AirSpec + +// extracted from wvlet.airframe.di.PathDependentTypeTest + +class PathDependentTypeTest extends AirSpec { + test("pass dependent types") { + import PathDependentType.* + val s = Surface.of[MyProfile#Backend#Database] + assert(s.name == "Database") + assert(s.toString == "Database:=DatabaseDef") + } +} + +object PathDependentType { + object MyBackend extends MyBackend + + class MyService(val p: MyProfile#Backend#Database) + + trait MyProfile { + type Backend = MyBackend + } + + trait MyBackend { + type Database = DatabaseDef + class DatabaseDef { + def hello = "hello my" + } + } +}