From 838e695288df4c2082727253c138523ddea4bede Mon Sep 17 00:00:00 2001 From: Aleksander Rainko Date: Sun, 26 Nov 2023 07:32:42 +0100 Subject: [PATCH] tune path rendering to be copy-pastable --- .../io/github/arainko/ducktape/internal/Path.scala | 5 ++++- .../ducktape/total/DerivedTransformerSuite.scala | 2 +- .../arainko/ducktape/total/ErrorReportingSuite.scala | 12 ++++++------ .../ducktape/total/NestedConfigurationSuite.scala | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ducktapeNext/src/main/scala/io/github/arainko/ducktape/internal/Path.scala b/ducktapeNext/src/main/scala/io/github/arainko/ducktape/internal/Path.scala index 579cc47e..e7da3699 100644 --- a/ducktapeNext/src/main/scala/io/github/arainko/ducktape/internal/Path.scala +++ b/ducktapeNext/src/main/scala/io/github/arainko/ducktape/internal/Path.scala @@ -53,7 +53,10 @@ private[ducktape] final case class Path(root: Type[?], segments: Vector[Path.Seg else self.segments.map { case Path.Segment.Field(_, name) => name - case Path.Segment.Case(tpe) => s"at[${tpe.repr.show(using Printer.TypeReprAnsiCode)}]" + case Path.Segment.Case(tpe) => + val repr = tpe.repr + val suffix = if (repr.isSingleton) ".type" else "" + s"at[${tpe.repr.show(using Printer.TypeReprAnsiCode)}${suffix}]" }.mkString(s"$printedRoot.", ".", "") } } diff --git a/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/DerivedTransformerSuite.scala b/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/DerivedTransformerSuite.scala index 7ba6ccba..9474c002 100644 --- a/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/DerivedTransformerSuite.scala +++ b/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/DerivedTransformerSuite.scala @@ -373,7 +373,7 @@ class DerivedTransformerSuite extends DucktapeSuite { test("derivation fails when going from a sum with more cases to a sum with less cases") { assertFailsToCompileWith("MoreCases.Case3.to[LessCases]")( - "No child named 'Case4' found in io.github.arainko.ducktape.total.DerivedTransformerSuite.LessCases @ MoreCases.at[io.github.arainko.ducktape.total.DerivedTransformerSuite.MoreCases.Case4]" + "No child named 'Case4' found in io.github.arainko.ducktape.total.DerivedTransformerSuite.LessCases @ MoreCases.at[io.github.arainko.ducktape.total.DerivedTransformerSuite.MoreCases.Case4.type]" ) } diff --git a/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/ErrorReportingSuite.scala b/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/ErrorReportingSuite.scala index 7cfd93f6..f6ac17c5 100644 --- a/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/ErrorReportingSuite.scala +++ b/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/ErrorReportingSuite.scala @@ -66,11 +66,11 @@ class ErrorReportingSuite extends DucktapeSuite { source.to[DestToplevel1] """ } { - """No child named 'Level1Extra2' found in DestToplevel1 @ SourceToplevel1.at[SourceToplevel1.Level1Extra2] - |No child named 'Level1Extra1' found in DestToplevel1 @ SourceToplevel1.at[SourceToplevel1.Level1Extra1] - |No child named 'Level2Extra2' found in DestLevel2 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2Extra2] - |No child named 'Level2Extra1' found in DestLevel2 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2Extra1] - |No child named 'Extra' found in DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra]""".stripMargin + """No child named 'Level1Extra2' found in DestToplevel1 @ SourceToplevel1.at[SourceToplevel1.Level1Extra2.type] + |No child named 'Level1Extra1' found in DestToplevel1 @ SourceToplevel1.at[SourceToplevel1.Level1Extra1.type] + |No child named 'Level2Extra2' found in DestLevel2 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2Extra2.type] + |No child named 'Level2Extra1' found in DestLevel2 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2Extra1.type] + |No child named 'Extra' found in DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra.type]""".stripMargin } }: @nowarn("msg=unused local definition") @@ -130,7 +130,7 @@ class ErrorReportingSuite extends DucktapeSuite { source.into[DestToplevel1].transform(Case.const(_.at[SourceToplevel1.Level1].level2.at[SourceLevel2], 123)) """ }( - "No child named 'Extra' found in DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra]", + "No child named 'Extra' found in DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra.type]", "'at[SourceLevel2]' is not a valid case accessor @ SourceToplevel1.at[SourceToplevel1.Level1].level2" ) }: @nowarn("msg=unused local definition") diff --git a/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/NestedConfigurationSuite.scala b/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/NestedConfigurationSuite.scala index e3c8e0d8..5620c30b 100644 --- a/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/NestedConfigurationSuite.scala +++ b/ducktapeNext/src/test/scala/io/github/arainko/ducktape/total/NestedConfigurationSuite.scala @@ -406,8 +406,8 @@ class NestedConfigurationSuite extends DucktapeSuite { ) """ }( - "No child named 'Extra' found in DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra]", - "Configuration is not valid since the provided type (123) is not a subtype of DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra]" + "No child named 'Extra' found in DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra.type]", + "Configuration is not valid since the provided type (123) is not a subtype of DestLevel3 @ SourceToplevel1.at[SourceToplevel1.Level1].level2.at[SourceLevel2.Level2].level3.at[SourceLevel3.Extra.type]" ) }: @nowarn("msg=unused local definition")