Skip to content

Commit

Permalink
tune path rendering to be copy-pastable
Browse files Browse the repository at this point in the history
  • Loading branch information
arainko committed Nov 26, 2023
1 parent d4fc97d commit 838e695
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.", ".", "")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 838e695

Please sign in to comment.